Andrea Campanella | 362b7d3 | 2018-12-11 18:57:12 +0100 | [diff] [blame] | 1 | export function getSips() { |
| 2 | |
| 3 | return new Promise((resolve, reject) => { |
| 4 | fetch(`/dcs/operations/tapi-common:get-service-interface-point-list`, { |
| 5 | method: 'POST', |
| 6 | headers: { |
| 7 | "Content-Type": "application/json", |
| 8 | }, |
| 9 | body: "{}" |
| 10 | }) |
| 11 | .then(res => { |
| 12 | if (res.ok) { |
| 13 | res.json().then(data => resolve(data["tapi-common:output"]["sip"])) |
| 14 | } else { |
| 15 | reject(res.text()) |
| 16 | } |
| 17 | }) |
| 18 | .catch(err => { |
| 19 | console.error(err) |
| 20 | }) |
| 21 | }) |
| 22 | } |
| 23 | |
| 24 | export function getSipDetail(uuid) { |
| 25 | |
| 26 | return new Promise((resolve, reject) => { |
| 27 | fetch(`/dcs/data/tapi-common:context/service-interface-point=${uuid}`, { |
| 28 | method: 'GET', |
| 29 | }) |
| 30 | .then(res => { |
| 31 | if (res.ok) { |
| 32 | res.json().then(data => resolve(data["tapi-common:service-interface-point"][0])) |
| 33 | } else { |
| 34 | reject(res.text()) |
| 35 | } |
| 36 | }) |
| 37 | .catch(err => { |
| 38 | console.error(err) |
| 39 | }) |
| 40 | }) |
| 41 | } |
| 42 | |
| 43 | |
| 44 | export function getConnectivityServices() { |
| 45 | |
| 46 | return new Promise((resolve, reject) => { |
| 47 | fetch(`/dcs/operations/tapi-connectivity:get-connectivity-service-list`, { |
| 48 | method: 'POST', |
| 49 | headers: { |
| 50 | "Content-Type": "application/json", |
| 51 | }, |
| 52 | body: '{}' |
| 53 | }) |
| 54 | .then(res => { |
| 55 | console.log(res) |
| 56 | if (res.ok) { |
| 57 | res.json().then(data => resolve(data["tapi-connectivity:output"]["service"])) |
| 58 | } else { |
| 59 | reject(res.text()) |
| 60 | } |
| 61 | }) |
| 62 | .catch(err => { |
| 63 | console.error(err) |
| 64 | }) |
| 65 | }) |
| 66 | } |
| 67 | |
| 68 | |
Hiroki Okui | 458da6d | 2019-02-15 10:09:21 -0800 | [diff] [blame] | 69 | export function createClientSideConnectivityService( sip1, sip2) { |
Andrea Campanella | 362b7d3 | 2018-12-11 18:57:12 +0100 | [diff] [blame] | 70 | |
| 71 | return new Promise((resolve, reject) => { |
| 72 | fetch(`/dcs/operations/tapi-connectivity:create-connectivity-service`, { |
| 73 | method: 'POST', |
| 74 | headers: { |
| 75 | "Content-Type": "application/json", |
| 76 | }, |
Hiroki Okui | 458da6d | 2019-02-15 10:09:21 -0800 | [diff] [blame] | 77 | body: getCreateClientSideRequestBody(sip1, sip2) |
Andrea Campanella | 362b7d3 | 2018-12-11 18:57:12 +0100 | [diff] [blame] | 78 | }) |
| 79 | .then(res => { |
| 80 | console.log(res) |
| 81 | if (res.ok) { |
| 82 | res.json().then(data => resolve(data["tapi-connectivity:output"]["service"])) |
| 83 | } else { |
| 84 | reject(res.text()) |
| 85 | } |
| 86 | }) |
| 87 | .catch(err => { |
| 88 | console.error(err) |
| 89 | }) |
| 90 | }) |
| 91 | } |
| 92 | |
Hiroki Okui | 458da6d | 2019-02-15 10:09:21 -0800 | [diff] [blame] | 93 | export function createLineSideConnectivityService( sip1, sip2) { |
| 94 | |
| 95 | return new Promise((resolve, reject) => { |
| 96 | fetch(`/dcs/operations/tapi-connectivity:create-connectivity-service`, { |
| 97 | method: 'POST', |
| 98 | headers: { |
| 99 | "Content-Type": "application/json", |
| 100 | }, |
| 101 | body: getCreateLineSideRequestBody(sip1, sip2) |
| 102 | }) |
| 103 | .then(res => { |
| 104 | console.log(res) |
| 105 | if (res.ok) { |
| 106 | res.json().then(data => resolve(data["tapi-connectivity:output"]["service"])) |
| 107 | } else { |
| 108 | reject(res.text()) |
| 109 | } |
| 110 | }) |
| 111 | .catch(err => { |
| 112 | console.error(err) |
| 113 | }) |
| 114 | }) |
| 115 | } |
Andrea Campanella | 362b7d3 | 2018-12-11 18:57:12 +0100 | [diff] [blame] | 116 | |
| 117 | export function deleteConnectivityServices(uuid) { |
| 118 | |
| 119 | return new Promise((resolve, reject) => { |
| 120 | fetch(`/dcs/operations/tapi-connectivity:delete-connectivity-service`, { |
| 121 | method: 'POST', |
| 122 | headers: { |
| 123 | "Content-Type": "application/json", |
| 124 | }, |
| 125 | body: getDeleteRequestBody(uuid) |
| 126 | }) |
| 127 | .then(res => { |
| 128 | console.log(res) |
| 129 | if (res.ok) { |
| 130 | resolve() |
| 131 | } else { |
| 132 | reject(res.text()) |
| 133 | } |
| 134 | }) |
| 135 | .catch(err => { |
| 136 | console.error(err) |
| 137 | }) |
| 138 | }) |
| 139 | } |
| 140 | |
| 141 | |
Hiroki Okui | 458da6d | 2019-02-15 10:09:21 -0800 | [diff] [blame] | 142 | function getCreateLineSideRequestBody(sip1, sip2){ |
Andrea Campanella | 362b7d3 | 2018-12-11 18:57:12 +0100 | [diff] [blame] | 143 | return `{ |
| 144 | "tapi-connectivity:input": |
| 145 | { |
| 146 | "end-point" : [ |
| 147 | { |
| 148 | "local-id": "id1", |
| 149 | "service-interface-point": { |
| 150 | "service-interface-point-uuid" : "${sip1}" |
Hiroki Okui | 458da6d | 2019-02-15 10:09:21 -0800 | [diff] [blame] | 151 | }, |
| 152 | "layer-protocol-qualifier" : "tapi-photonic-media:PHOTONIC_LAYER_QUALIFIER_NMC", |
| 153 | "direction": "BIDIRECTIONAL", |
| 154 | "protection-role": "WORK", |
| 155 | "layer-protocol-name": "PHOTONIC_MEDIA" |
Andrea Campanella | 362b7d3 | 2018-12-11 18:57:12 +0100 | [diff] [blame] | 156 | } |
| 157 | , |
| 158 | { |
| 159 | "local-id": "id2", |
| 160 | "service-interface-point": { |
| 161 | "service-interface-point-uuid" : "${sip2}" |
Hiroki Okui | 458da6d | 2019-02-15 10:09:21 -0800 | [diff] [blame] | 162 | }, |
| 163 | "layer-protocol-qualifier" : "tapi-photonic-media:PHOTONIC_LAYER_QUALIFIER_NMC", |
| 164 | "direction": "BIDIRECTIONAL", |
| 165 | "protection-role": "WORK", |
| 166 | "layer-protocol-name": "PHOTONIC_MEDIA" |
| 167 | } |
| 168 | ] |
| 169 | } |
| 170 | }` |
| 171 | } |
| 172 | |
| 173 | function getCreateClientSideRequestBody(sip1, sip2){ |
| 174 | return `{ |
| 175 | "tapi-connectivity:input": |
| 176 | { |
| 177 | "end-point" : [ |
| 178 | { |
| 179 | "local-id": "id1", |
| 180 | "service-interface-point": { |
| 181 | "service-interface-point-uuid" : "${sip1}" |
| 182 | }, |
| 183 | "layer-protocol-name": "DSR" |
| 184 | } |
| 185 | , |
| 186 | { |
| 187 | "local-id": "id2", |
| 188 | "service-interface-point": { |
| 189 | "service-interface-point-uuid" : "${sip2}" |
| 190 | }, |
| 191 | "layer-protocol-name": "DSR" |
Andrea Campanella | 362b7d3 | 2018-12-11 18:57:12 +0100 | [diff] [blame] | 192 | } |
| 193 | ] |
| 194 | } |
| 195 | }` |
| 196 | } |
| 197 | |
| 198 | function getDeleteRequestBody(uuid){ |
| 199 | return `{ |
| 200 | "tapi-connectivity:input": |
| 201 | { |
| 202 | "service-id-or-name" : "${uuid}" |
| 203 | } |
| 204 | }` |
| 205 | } |