aboutsummaryrefslogtreecommitdiffstats
path: root/BULK.md
blob: 9f2f3dd04ed09838d89cd3cc735f5c5a653d2f5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
## Bulk API

The bulk API allows a client to add/modify/patch/delete multiple vertexes and/or edges within a single request.  This request will be treated as an atomic transaction in that all operations within the bulk request will either fail or succeed together. This is often useful when attempting to add an entire subgraph.

The following example shows how a client could create 2 vertexes (pserver and vserver) and link them with an edge. In the JSON body, the order in which vertex and edge operations are defined within the `objects` and `relationships` arrays is not important. The bulk API will handle the operations requested in a logical order to preserve data integrity.

    URL: https://<host>:9520/services/inventory/v11/bulk
    Method: POST
    Body:
        {
            "objects":[
                {
                    "operation":"add",
                    "v1":{
                        "type":"vserver",
                        "properties":{
                            "in-maint":false,
                            "vserver-name":"vserver1",
                            "prov-status":"Provisioned",
                            "vserver-id":"Vserver-AMT-002-HSGW",
                            "vserver-name2":"Vs2-HSGW-OTT",
                            "vserver-selflink":"AMT VserverLink",
                            "is-closed-loop-disabled":false
                        }
                    }
                },
                {
                    "operation":"add",
                    "v2":{
                        "type":"pserver",
                        "properties":{
                            "ptnii-equip-name":"ps1993",
                            "hostname":"pserver1",
                            "equip-type":"server",
                            "equip-vendor":"HP",
                            "equip-model":"DL380p-nd",
                            "in-maint":false,
                            "fqdn":"pserver1.lab.com",
                            "ipv4-oam-address":"199.1.138.60"
                        }
                    }
                }
            ],
            "relationships":[
                {
                    "operation":"add",
                    "e1":{
                        "type":"tosca.relationships.HostedOn",
                        "source":"$v1",
                        "target":"$v2",
                        "properties":{
                            "contains-other-v": "NONE",
                            "delete-other-v": "NONE",
                            "SVC-INFRA": "OUT",
                            "prevent-delete": "IN"
                        }
                    }
                }
            ]
        }

    Success Response:
        Code: 200
        Content:
            {
                "objects": [
                    {
                        "operation": "add",
                        "v1": {
                            "id": "1024143488",
                            "type": "vserver",
                            "url": "services/inventory/v11/vserver/1024143488",
                            "properties": {
                                "in-maint":false,
                                "vserver-name":"vserver1",
                                "prov-status":"Provisioned",
                                "vserver-id":"Vserver-AMT-002-HSGW",
                                "vserver-name2":"Vs2-HSGW-OTT",
                                "vserver-selflink":"AMT VserverLink",
                                "is-closed-loop-disabled":false
                            },
                            "in": [],
                            "out": []
                        }
                    },
                    {
                        "operation": "add",
                        "v2": {
                            "id": "1228865600",
                            "type": "pserver",
                            "url": "services/inventory/v11/pserver/1228865600",
                            "properties": {
                                "ptnii-equip-name":"ps1993",
                                "hostname":"pserver1",
                                "equip-type":"server",
                                "equip-vendor":"HP",
                                "equip-model":"DL380p-nd",
                                "in-maint":false,
                                "fqdn":"pserver1.lab.com",
                                "ipv4-oam-address":"199.1.138.60"
                            },
                            "in": [],
                            "out": []
                        }
                    }
                ],
                "relationships": [
                    {
                        "operation": "add",
                        "e1": {
                            "id": "kbrs40-gxqy68-108id-kbmurk",
                            "type": "tosca.relationships.HostedOn",
                            "url": "services/inventory/relationships/v11/tosca.relationships.HostedOn/kbrs40-gxqy68-108id-kbmurk",
                            "source": "services/inventory/v11/vserver/1024143488",
                            "target": "services/inventory/v11/pserver/1228865600",
                            "properties": {
                                "SVC-INFRA": "OUT",
                                "prevent-delete": "IN",
                                "delete-other-v": "NONE",
                                "contains-other-v": "NONE"
                            }
                        }
                    }
                ]
            }

    Error Response:
        Code: 400 (BAD REQUEST)
        Content: Error message describing the bad request failure.
        Situation: Invalid Payload or schema error.

        Code: 403 (FORBIDDEN)
        Content: Error message describing the Authorization failure.
        Situation: Authorization failure.

        Code: 415 (UNSUPPORTED MEDIA TYPE)
        Situation: Unsupported content type .

        Code: 500 (Internal Server Error)
        Content: Error message describing the failure.
        Situation: Any scenario not covered by the above error codes.