-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from cisco-open/hh-telephony
Support Telephony Items
- Loading branch information
Showing
17 changed files
with
388 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2023 Cisco Systems, Inc. and its affiliates | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
// | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package tbclient | ||
|
||
func (c *Client) getInventoryTelephonyService(topologyUid string) *collectionService[InventoryTelephonyItem, inventoryTelephonyItemCollection] { | ||
return &collectionService[InventoryTelephonyItem, inventoryTelephonyItemCollection]{ | ||
client: c, | ||
resourcePath: "/inventory-telephony-items", | ||
topologyUid: topologyUid, | ||
} | ||
} | ||
|
||
func (c *Client) getTelephonyItemService(topologyUid string) *resourceService[TelephonyItem, telephonyItemCollection] { | ||
return &resourceService[TelephonyItem, telephonyItemCollection]{ | ||
collectionService[TelephonyItem, telephonyItemCollection]{ | ||
client: c, | ||
resourcePath: "/telephony-items", | ||
topologyUid: topologyUid, | ||
}, | ||
} | ||
} | ||
|
||
func (c *Client) GetAllInventoryTelephonyItems(topologyUid string) ([]InventoryTelephonyItem, error) { | ||
return c.getInventoryTelephonyService(topologyUid).getAll() | ||
} | ||
|
||
func (c *Client) GetAllTelephonyItems(topologyUid string) ([]TelephonyItem, error) { | ||
return c.getTelephonyItemService(topologyUid).getAll() | ||
} | ||
|
||
func (c *Client) CreateTelephonyItem(telephonyItem TelephonyItem) (*TelephonyItem, error) { | ||
return c.getTelephonyItemService("").create(telephonyItem) | ||
} | ||
|
||
func (c *Client) DeleteTelephonyItem(uid string) error { | ||
return c.getTelephonyItemService("").delete(uid) | ||
} |
26 changes: 26 additions & 0 deletions
26
tbclient/test_stubs/mappings/telephony/createTelephonyItem_BadRequest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"id" : "1f566c32-001c-4781-97d6-c7811210f0da", | ||
"request" : { | ||
"urlPath" : "/telephony-items", | ||
"method" : "POST", | ||
"headers" : { | ||
"Content-Type" : { | ||
"contains" : "application/json" | ||
} | ||
}, | ||
"bodyPatterns" : [ { | ||
"matchesJsonPath" : "$.['inventoryTelephonyItem'][?(@.['id'] == 'notfound')]" | ||
}, { | ||
"matchesJsonPath" : "$.['topology'][?(@.['uid'] == 'rtptopology')]" | ||
} ] | ||
}, | ||
"response" : { | ||
"status" : 400, | ||
"body" : "[{\"logref\":\"GURCFMVPSICDZQWHNJJY\",\"message\":\"The requested dCloud Telephony resource 'notfound' was not found\",\"links\":[]}]", | ||
"headers" : { | ||
"Content-Type" : "application/vnd.error+json" | ||
}, | ||
"transformers" : [ "response-template", "spring-cloud-contract" ] | ||
}, | ||
"uuid" : "1f566c32-001c-4781-97d6-c7811210f0da" | ||
} |
27 changes: 27 additions & 0 deletions
27
tbclient/test_stubs/mappings/telephony/createTelephonyItem_Success.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"id" : "11b6660d-a691-46c6-bb0f-ca4fe2ae7f6a", | ||
"request" : { | ||
"urlPath" : "/telephony-items", | ||
"method" : "POST", | ||
"headers" : { | ||
"Content-Type" : { | ||
"contains" : "application/json" | ||
} | ||
}, | ||
"bodyPatterns" : [ { | ||
"matchesJsonPath" : "$.['inventoryTelephonyItem'][?(@.['id'] == '1')]" | ||
}, { | ||
"matchesJsonPath" : "$.['topology'][?(@.['uid'] == 'rtptopology')]" | ||
} ] | ||
}, | ||
"response" : { | ||
"status" : 201, | ||
"body" : "{\"uid\":\"newtelephonyitem\",\"name\":\"PSTN Services\",\"inventoryTelephonyItem\":{\"id\":\"{{{jsonPath request.body '$.inventoryTelephonyItem.id'}}}\",\"name\":\"PSTN Services\",\"description\":\"PSTN Services (VCube)\"},\"topology\":{\"uid\":\"{{{jsonPath request.body '$.topology.uid'}}}\"},\"_links\":{\"self\":{\"href\":\"http://localhost{{{request.url}}}/newtelephonyitem\"},\"topology\":{\"href\":\"http://localhost/topologies/{{{jsonPath request.body '$.topology.uid'}}}\"},\"delete\":{\"href\":\"http://localhost{{{request.url}}}/newtelephonyitem\"}}}", | ||
"headers" : { | ||
"Content-Type" : "application/json", | ||
"ETag" : "FIX_ETAG_FOR_TESTS" | ||
}, | ||
"transformers" : [ "response-template", "spring-cloud-contract" ] | ||
}, | ||
"uuid" : "11b6660d-a691-46c6-bb0f-ca4fe2ae7f6a" | ||
} |
26 changes: 26 additions & 0 deletions
26
tbclient/test_stubs/mappings/telephony/createTelephonyItem_readerUnavailable.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"id" : "58e1c934-f053-4c77-970c-6ebf408777bc", | ||
"request" : { | ||
"urlPath" : "/telephony-items", | ||
"method" : "POST", | ||
"headers" : { | ||
"Content-Type" : { | ||
"contains" : "application/json" | ||
} | ||
}, | ||
"bodyPatterns" : [ { | ||
"matchesJsonPath" : "$.['inventoryTelephonyItem'][?(@.['id'] == '1')]" | ||
}, { | ||
"matchesJsonPath" : "$.['topology'][?(@.['uid'] == 'noreader')]" | ||
} ] | ||
}, | ||
"response" : { | ||
"status" : 503, | ||
"body" : "[{\"logref\":\"ZCYSJESBKVUKPDRSOTFZ\",\"message\":\"Connectivity to the SNG V2 Reader service has not been configured\",\"links\":[]}]", | ||
"headers" : { | ||
"Content-Type" : "application/vnd.error+json" | ||
}, | ||
"transformers" : [ "response-template", "spring-cloud-contract" ] | ||
}, | ||
"uuid" : "58e1c934-f053-4c77-970c-6ebf408777bc" | ||
} |
12 changes: 12 additions & 0 deletions
12
tbclient/test_stubs/mappings/telephony/deleteTelephonyItem_notFound.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"id" : "448e3d73-75d1-4ce1-86f1-160dfce37e35", | ||
"request" : { | ||
"urlPath" : "/telephony-items/notfound", | ||
"method" : "DELETE" | ||
}, | ||
"response" : { | ||
"status" : 404, | ||
"transformers" : [ "response-template", "spring-cloud-contract" ] | ||
}, | ||
"uuid" : "448e3d73-75d1-4ce1-86f1-160dfce37e35" | ||
} |
12 changes: 12 additions & 0 deletions
12
tbclient/test_stubs/mappings/telephony/deleteTelephonyItem_success.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"id" : "c86f46e6-a3ac-4360-8861-47a556ed4164", | ||
"request" : { | ||
"urlPath" : "/telephony-items/lontelephonyitem1", | ||
"method" : "DELETE" | ||
}, | ||
"response" : { | ||
"status" : 204, | ||
"transformers" : [ "response-template", "spring-cloud-contract" ] | ||
}, | ||
"uuid" : "c86f46e6-a3ac-4360-8861-47a556ed4164" | ||
} |
16 changes: 16 additions & 0 deletions
16
tbclient/test_stubs/mappings/telephony/getInventoryTelephonyItems_lonTopology.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"id" : "c0d4fc0e-1809-4be9-a986-738300f9cefe", | ||
"request" : { | ||
"urlPath" : "/topologies/lontopology/inventory-telephony-items", | ||
"method" : "GET" | ||
}, | ||
"response" : { | ||
"status" : 200, | ||
"body" : "{\"_embedded\":{\"inventoryTelephonyItems\":[{\"id\":\"1\",\"name\":\"PSTN Services\",\"description\":\"PSTN Services (VCube)\"}]},\"_links\":{\"self\":{\"href\":\"http://localhost{{{request.url}}}\"}}}", | ||
"headers" : { | ||
"Content-Type" : "application/json" | ||
}, | ||
"transformers" : [ "response-template", "spring-cloud-contract" ] | ||
}, | ||
"uuid" : "c0d4fc0e-1809-4be9-a986-738300f9cefe" | ||
} |
16 changes: 16 additions & 0 deletions
16
tbclient/test_stubs/mappings/telephony/getInventoryTelephonyItems_readerUnavailable.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"id" : "a2a4de75-efd1-4f55-8234-d197904afcb6", | ||
"request" : { | ||
"urlPath" : "/topologies/noreader/inventory-telephony-items", | ||
"method" : "GET" | ||
}, | ||
"response" : { | ||
"status" : 503, | ||
"body" : "[{\"logref\":\"LHNSNITENRLVTVQBMZWQ\",\"message\":\"Connectivity to the SNG V2 Reader service has not been configured\",\"links\":[]}]", | ||
"headers" : { | ||
"Content-Type" : "application/vnd.error+json" | ||
}, | ||
"transformers" : [ "response-template", "spring-cloud-contract" ] | ||
}, | ||
"uuid" : "a2a4de75-efd1-4f55-8234-d197904afcb6" | ||
} |
16 changes: 16 additions & 0 deletions
16
tbclient/test_stubs/mappings/telephony/getInventoryTelephonyItems_rtpTopology.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"id" : "acddc6a2-286d-4687-84ba-97d16f6394f2", | ||
"request" : { | ||
"urlPath" : "/topologies/rtptopology/inventory-telephony-items", | ||
"method" : "GET" | ||
}, | ||
"response" : { | ||
"status" : 200, | ||
"body" : "{\"_embedded\":{\"inventoryTelephonyItems\":[{\"id\":\"1\",\"name\":\"PSTN Services\",\"description\":\"PSTN Services (VCube)\"}]},\"_links\":{\"self\":{\"href\":\"http://localhost{{{request.url}}}\"}}}", | ||
"headers" : { | ||
"Content-Type" : "application/json" | ||
}, | ||
"transformers" : [ "response-template", "spring-cloud-contract" ] | ||
}, | ||
"uuid" : "acddc6a2-286d-4687-84ba-97d16f6394f2" | ||
} |
16 changes: 16 additions & 0 deletions
16
tbclient/test_stubs/mappings/telephony/getInventoryTelephonyItems_topologyNotFound.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"id" : "0439e77e-3a42-4ca6-95a5-4a1309b85821", | ||
"request" : { | ||
"urlPath" : "/topologies/notfound/inventory-telephony-items", | ||
"method" : "GET" | ||
}, | ||
"response" : { | ||
"status" : 404, | ||
"body" : "[{\"logref\":\"EWWJZWAWYUSMGDHVNGVN\",\"message\":\"The requested Topology resource was not found\",\"links\":[]}]", | ||
"headers" : { | ||
"Content-Type" : "application/vnd.error+json" | ||
}, | ||
"transformers" : [ "response-template", "spring-cloud-contract" ] | ||
}, | ||
"uuid" : "0439e77e-3a42-4ca6-95a5-4a1309b85821" | ||
} |
16 changes: 16 additions & 0 deletions
16
tbclient/test_stubs/mappings/telephony/getTelephonyItems_empty.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"id" : "61433472-b693-4163-b1f9-e4a4ef29856d", | ||
"request" : { | ||
"urlPath" : "/topologies/rtptopology/telephony-items", | ||
"method" : "GET" | ||
}, | ||
"response" : { | ||
"status" : 200, | ||
"body" : "{\"_embedded\":{\"telephonyItems\":[]},\"_links\":{\"self\":{\"href\":\"http://localhost/topologies/rtptopology/telephony-items\"}}}", | ||
"headers" : { | ||
"Content-Type" : "application/json" | ||
}, | ||
"transformers" : [ "response-template", "spring-cloud-contract" ] | ||
}, | ||
"uuid" : "61433472-b693-4163-b1f9-e4a4ef29856d" | ||
} |
16 changes: 16 additions & 0 deletions
16
tbclient/test_stubs/mappings/telephony/getTelephonyItems_readerUnavailable.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"id" : "7d8a79f0-d169-4f28-9e70-d634aa841d43", | ||
"request" : { | ||
"urlPath" : "/topologies/noreader/telephony-items", | ||
"method" : "GET" | ||
}, | ||
"response" : { | ||
"status" : 503, | ||
"body" : "[{\"logref\":\"XKQSUJIVCGVEGQTMSKFW\",\"message\":\"Connectivity to the SNG V2 Reader service has not been configured\",\"links\":[]}]", | ||
"headers" : { | ||
"Content-Type" : "application/vnd.error+json" | ||
}, | ||
"transformers" : [ "response-template", "spring-cloud-contract" ] | ||
}, | ||
"uuid" : "7d8a79f0-d169-4f28-9e70-d634aa841d43" | ||
} |
16 changes: 16 additions & 0 deletions
16
tbclient/test_stubs/mappings/telephony/getTelephonyItems_success.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"id" : "f9ec35f1-8cff-47ee-8478-f2c3b3e6c702", | ||
"request" : { | ||
"urlPath" : "/topologies/lontopology/telephony-items", | ||
"method" : "GET" | ||
}, | ||
"response" : { | ||
"status" : 200, | ||
"body" : "{\"_embedded\":{\"telephonyItems\":[{\"uid\":\"lontelephonyitem1\",\"name\":\"PSTN Services\",\"inventoryTelephonyItem\":{\"id\":\"1\",\"name\":\"PSTN Services\",\"description\":\"PSTN Services (VCube)\"},\"topology\":{\"uid\":\"lontopology\"},\"_links\":{\"self\":{\"href\":\"http://localhost/telephony-items/lontelephonyitem1\"},\"delete\":{\"href\":\"http://localhost/telephony-items/lontelephonyitem1\"},\"topology\":{\"href\":\"http://localhost/topologies/lontopology\"}}}]},\"_links\":{\"self\":{\"href\":\"http://localhost/topologies/lontopology/telephony-items\"}}}", | ||
"headers" : { | ||
"Content-Type" : "application/json" | ||
}, | ||
"transformers" : [ "response-template", "spring-cloud-contract" ] | ||
}, | ||
"uuid" : "f9ec35f1-8cff-47ee-8478-f2c3b3e6c702" | ||
} |
Oops, something went wrong.