Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

Commit

Permalink
feat: add binding/unbinding endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
euhmeuh committed Sep 13, 2019
1 parent 8502c13 commit 58e2045
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 40 deletions.
8 changes: 4 additions & 4 deletions src/api/dedicated/server/dedicated-server.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
},
}));
4 changes: 2 additions & 2 deletions src/api/dedicated/server/nic/dedicated-server.nic.service.js
Original file line number Diff line number Diff line change
@@ -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');
},
}));
63 changes: 47 additions & 16 deletions src/api/dedicated/server/nic/dedicated-server.nic.v6.service.js
Original file line number Diff line number Diff line change
@@ -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;
});
4 changes: 2 additions & 2 deletions src/api/dedicated/server/vni/dedicated-server.vni.service.js
Original file line number Diff line number Diff line change
@@ -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');
},
}));
75 changes: 59 additions & 16 deletions src/api/dedicated/server/vni/dedicated-server.vni.v6.service.js
Original file line number Diff line number Diff line change
@@ -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;
});

0 comments on commit 58e2045

Please sign in to comment.