diff --git a/src/api/dedicated/server/dedicated-server.service.js b/src/api/dedicated/server/dedicated-server.service.js index a99ab892..fac0db56 100644 --- a/src/api/dedicated/server/dedicated-server.service.js +++ b/src/api/dedicated/server/dedicated-server.service.js @@ -5,10 +5,10 @@ angular.module('ovh-api-services').service('OvhApiDedicatedServer', $injector => Aapi() { return $injector.get('OvhApiDedicatedServerAapi'); }, - Nic() { - return $injector.get('OvhApiDedicatedServerNic'); + PhysicalInterface() { + return $injector.get('OvhApiDedicatedServerPhysicalInterface'); }, - Vni() { - return $injector.get('OvhApiDedicatedServerVni'); + VirtualInterface() { + return $injector.get('OvhApiDedicatedServerVirtualInterface'); }, })); diff --git a/src/api/dedicated/server/nic/dedicated-server.nic.service.js b/src/api/dedicated/server/nic/dedicated-server.nic.service.js index cb1c0880..8fac3a0d 100644 --- a/src/api/dedicated/server/nic/dedicated-server.nic.service.js +++ b/src/api/dedicated/server/nic/dedicated-server.nic.service.js @@ -1,5 +1,5 @@ -angular.module('ovh-api-services').service('OvhApiDedicatedServerNic', $injector => ({ +angular.module('ovh-api-services').service('OvhApiDedicatedServerPhysicalInterface', $injector => ({ v6() { - return $injector.get('OvhApiDedicatedServerNicV6'); + return $injector.get('OvhApiDedicatedServerPhysicalInterfaceV6'); }, })); diff --git a/src/api/dedicated/server/nic/dedicated-server.nic.v6.service.js b/src/api/dedicated/server/nic/dedicated-server.nic.v6.service.js index c5bdd9e8..ffbd7337 100644 --- a/src/api/dedicated/server/nic/dedicated-server.nic.v6.service.js +++ b/src/api/dedicated/server/nic/dedicated-server.nic.v6.service.js @@ -1,30 +1,61 @@ -angular.module('ovh-api-services').service('OvhApiDedicatedServerNicV6', ($resource, $cacheFactory) => { - const otherCache = $cacheFactory('OvhApiDedicatedServerNicV6'); - const queryCache = $cacheFactory('OvhApiDedicatedServerNicV6Query'); +angular.module('ovh-api-services').service('OvhApiDedicatedServerPhysicalInterfaceV6', ($resource, $cacheFactory) => { + const cache = $cacheFactory('OvhApiDedicatedServerPhysicalInterfaceV6'); - const dedicatedServerNicResource = $resource('/dedicated/server/:serverName/networkInterfaceController', { + const interceptor = { + response(response) { + dedicatedServerPhysicalInterfaceResource.resetCache(); + return response.data; + }, + }; + + const dedicatedServerPhysicalInterfaceResource = $resource('/dedicated/server/:serverName/networkInterfaceController', { serverName: '@serverName', }, { - query: { method: 'GET', cache: queryCache, isArray: true }, + query: { + method: 'GET', + cache, + isArray: true, + params: { + linkType: '@linkType', + }, + }, get: { url: '/dedicated/server/:serverName/networkInterfaceController/:mac', method: 'GET', - cache: otherCache, + cache, + }, + mrtg: { + url: '/dedicated/server/:serverName/networkInterfaceController/:mac/mrtg', + method: 'GET', + cache, + isArray: true, + params: { + period: '@period', + type: '@type', + }, + }, + bind: { + url: '/dedicated/server/:serverName/networkInterfaceController/:mac/bind', + method: 'POST', + interceptor, + params: { + virtualNetworkInterface: '@virtualNetworkInterface', + }, + }, + unbind: { + url: '/dedicated/server/:serverName/networkInterfaceController/:mac/unbind', + method: 'POST', + interceptor, }, }); - dedicatedServerNicResource.resetAllCache = function resetAllCache() { - dedicatedServerNicResource.resetOtherCache(); - dedicatedServerNicResource.resetQueryCache(); - }; - - dedicatedServerNicResource.resetOtherCache = function resetOtherCache() { - otherCache.removeAll(); + dedicatedServerPhysicalInterfaceResource.resetAllCache = function resetAllCache() { + dedicatedServerPhysicalInterfaceResource.resetCache(); }; - dedicatedServerNicResource.resetQueryCache = function resetQueryCache() { - queryCache.removeAll(); + dedicatedServerPhysicalInterfaceResource.resetCache = function resetCache() { + cache.removeAll(); }; - return dedicatedServerNicResource; + return dedicatedServerPhysicalInterfaceResource; }); diff --git a/src/api/dedicated/server/vni/dedicated-server.vni.service.js b/src/api/dedicated/server/vni/dedicated-server.vni.service.js index c6256a26..15092254 100644 --- a/src/api/dedicated/server/vni/dedicated-server.vni.service.js +++ b/src/api/dedicated/server/vni/dedicated-server.vni.service.js @@ -1,5 +1,5 @@ -angular.module('ovh-api-services').service('OvhApiDedicatedServerVni', $injector => ({ +angular.module('ovh-api-services').service('OvhApiDedicatedServerVirtualInterface', $injector => ({ v6() { - return $injector.get('OvhApiDedicatedServerVniV6'); + return $injector.get('OvhApiDedicatedServerVirtualInterfaceV6'); }, })); diff --git a/src/api/dedicated/server/vni/dedicated-server.vni.v6.service.js b/src/api/dedicated/server/vni/dedicated-server.vni.v6.service.js index 6b74b0f1..8fcb23a5 100644 --- a/src/api/dedicated/server/vni/dedicated-server.vni.v6.service.js +++ b/src/api/dedicated/server/vni/dedicated-server.vni.v6.service.js @@ -1,30 +1,73 @@ -angular.module('ovh-api-services').service('OvhApiDedicatedServerVniV6', ($resource, $cacheFactory) => { - const otherCache = $cacheFactory('OvhApiDedicatedServerVniV6'); - const queryCache = $cacheFactory('OvhApiDedicatedServerVniV6Query'); +angular.module('ovh-api-services').service('OvhApiDedicatedServerVirtualInterfaceV6', ($resource, $cacheFactory) => { + const cache = $cacheFactory('OvhApiDedicatedServerVirtualInterfaceV6'); - const dedicatedServerVniResource = $resource('/dedicated/server/:serverName/virtualNetworkInterface', { + const interceptor = { + response(response) { + dedicatedServerVirtualInterfaceResource.resetCache(); + return response.data; + }, + }; + + const dedicatedServerVirtualInterfaceResource = $resource('/dedicated/server/:serverName/virtualNetworkInterface', { serverName: '@serverName', }, { - query: { method: 'GET', cache: queryCache, isArray: true }, + query: { + method: 'GET', + cache, + isArray: true, + params: { + enabled: '@enabled', + mode: '@mode', + name: '@name', + vrack: '@vrack', + }, + }, + create: { + url: '/dedicated/server/:serverName/virtualNetworkInterface', + method: 'POST', + interceptor, + params: { + mode: '@mode', + name: '@name', + }, + }, get: { url: '/dedicated/server/:serverName/virtualNetworkInterface/:uuid', method: 'GET', - cache: otherCache, + cache, + }, + update: { + url: '/dedicated/server/:serverName/virtualNetworkInterface/:uuid', + method: 'PUT', + interceptor, + params: { + VirtualNetworkInterface: '@virtualNetworkInterface', + }, + }, + delete: { + url: '/dedicated/server/:serverName/virtualNetworkInterface/:uuid', + method: 'DELETE', + interceptor, + }, + enable: { + url: '/dedicated/server/:serverName/virtualNetworkInterface/:uuid/enable', + method: 'POST', + interceptor, + }, + disable: { + url: '/dedicated/server/:serverName/virtualNetworkInterface/:uuid/disable', + method: 'POST', + interceptor, }, }); - dedicatedServerVniResource.resetAllCache = function resetAllCache() { - dedicatedServerVniResource.resetOtherCache(); - dedicatedServerVniResource.resetQueryCache(); - }; - - dedicatedServerVniResource.resetOtherCache = function resetOtherCache() { - otherCache.removeAll(); + dedicatedServerVirtualInterfaceResource.resetAllCache = function resetAllCache() { + dedicatedServerVirtualInterfaceResource.resetCache(); }; - dedicatedServerVniResource.resetQueryCache = function resetQueryCache() { - queryCache.removeAll(); + dedicatedServerVirtualInterfaceResource.resetCache = function resetCache() { + cache.removeAll(); }; - return dedicatedServerVniResource; + return dedicatedServerVirtualInterfaceResource; });