POST /macro

POST /macro

Macro API allows the user to create or delete an object hierarchy, which consists of a top level object and a set of objects it refers to in a recursive fashion.
An example usage would be to create or delete a VirtualService, Pool, and a set of custom profiles such as ApplicationProfile, NetworkProfile for every tenant.
Instead of using multiple APIs to create/delete the profiles, pool and the virtualservice, the user can just use one API to operate on the entire hierarchy of objects.
This API is transactional in nature in that if there is an error for any of the objects, the entire transaction will be rolled back. During deletion, default profiles and profiles that are in use by other objects will not be deleted.
Macro delete will not delete Tenant, Cloud, ServiceEngine, Network, NetworkRuntime, or VIMgr objects. During creation, user has the flexibility to refer to an existing object (eg. system profiles), or create a new object as a part of this object hierarchy.
Additionally, the same API can be used to modify any of the objects using PUT.

In the following example, the MACRO API is used to create a VirtualService, Pool and associated HealthMonitor object. The VirtualService refers to existing ApplicationProfile and NetworkProfile objects.

POST /api/macro
{
    "model_name": "VirtualService",
    "data": {
        "name": "n_vs",
        "services": [
            {
                "port": 80
            }
        ],
        "vip":[
            {
                "ip_address": {
                    "type": "V4",
                    "addr": "2.2.2.2"
                }
            }
        ],
        "application_profile_ref": "/api/applicationprofile?name=n_app_http",
        "pool_ref_data": {
            "name": "n_pool",
            "servers": [
                {
                    "ip": {
                        "type": "V4",
                        "addr": "1.1.1.1"
                    }
                }
            ],
            "health_monitor_refs_data": [
                {
                    "type": "HEALTH_MONITOR_HTTP",
                    "name": "n_http",
                    "http_monitor": {
                        "http_response_code": [
                            {
                                "code": "HTTP_2XX"
                            }
                        ]
                    }
                }
            ]
        } 
    }
}
Request
URI
POST
https://{api_host}/api/macro
COPY
Header Parameters
string
X-Avi-Tenant
Optional

Avi Tenant Header

string
X-Avi-Tenant-UUID
Optional

Avi Tenant Header UUID

string
X-Avi-Version
Required

The caller is required to set Avi Version Header to the expected version of configuration. The response from the controller will provide and accept data according to the specified version. The controller will reject POST and PUT requests where the data is not compatible with the specified version.

string
X-CSRFToken
Optional

Avi Controller may send back CSRF token in the response cookies. The caller should update the request headers with this token else controller will reject requests.


Request Body

Object creation

POST_Macro of type(s) application/json
Required
{
    "model_name": "string",
    "data": {}
}
string
model_name
Required

object name

object
data
Required

JSON object of the mentioned object name

Responses
200

OK

Operation doesn't return any data structure

401

log in failed

Operation doesn't return any data structure

Code Samples
COPY
                    curl -X POST -H 'Authorization: <value>' -H 'Content-Type: application/json' -d '{"model_name:"string","data:"object"}' https://{api_host}/api/macro