Skip to content

Commit f94806f

Browse files
authored
Merge pull request #63 from vidispine/release-1.26
Release 1.26
2 parents e07bd11 + 7d8c63a commit f94806f

3 files changed

Lines changed: 64 additions & 52 deletions

File tree

hull-vidispine-addon/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ apiVersion: v1
33
appVersion: 1.26.0
44
description: hull-vidispine-addon
55
name: hull-vidispine-addon
6-
version: 1.26.5
6+
version: 1.26.7

hull-vidispine-addon/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Describes a subresource on an endpoint which is communicated with. <br>Has exclu
8787
| ------------------------------- | ----------------------------------------------------------------| -----------------------------| -----------------------------------------|
8888
| `apiPath` | The relative path of the API on the endpoint | | `v1/Resource/ApiResource`
8989
| `typeDescription` | Description of the subresource
90-
| `identifierQueryParam` | Some APIs handle deletion of entities by DELETEing the parent resource and specifying the entity to delete in a query parameter. If the subresource handles DELETEion in that way, the query parameter to use for identifying the object needs to be stated here. If empty or unspecified, DELETE calls will be made to the path which ends with the entities name. || `"Guid"`
90+
| `identifierQueryParam` | Some APIs handle deletion of entities by DELETEing the parent resource and specifying the entity to delete in a query parameter. If the subresource handles DELETEion in that way, the query parameter to use for identifying the object needs to be stated here. If empty or unspecified, DELETE calls will be made to the path which ends with the entities identifier. NOTE: This setting usually needs entity setting 'deleteUriExcludeIdentifier' to be true as well! || `"Guid"`
9191
| `stage` | Stage where this `subresource` is processed. Overwrites `stage` from `endpoint` level. <br>All subresources are by default processed during execution of the `hull-install` job by setting stage `pre-install` before installation of the main product of the parent Helm Chart. If you for example need to communicate to the API of a product you just installed within the parents Helm chart, set the `stage` to `post-install` and the processing takes places within the `hull-configure` job after the main product installation is done. | `pre-install` | `post-install`
9292
| `auth` | Allows to override the `endpoint`s `auth` configuration at the `subresource` scope<br><br>Has one of following keys:<br>`basic`<br>`token`
9393
| `_DEFAULTS_` | Defaults for all `entity` objects defined under this `endpoint`. Can be used to set all `entity` properties to a default value. Technically all `entity` values will be merged on top of the `_DEFAULTS_` | | `_DEFAULTS_:`<br>&#160;&#160;`register:`&#160;`true`<br>&#160;&#160;`overwriteExisting:`&#160;`false`
@@ -99,8 +99,9 @@ Describes a particular entity on a subresource on an endpoint which is communica
9999
| Parameter | Description | Defaults | Example |
100100
| ------------------------------- | ----------------------------------------------------------------| -----------------------------| -----------------------------------------|
101101
| `register` | If set to true, the entity will be created or modified |
102-
| `remove` | The entity will be DELETEd if it exists
103-
| `identifier` | Optional field to specify the objects 'identifier', if not set or empty the object 'identifier' will be set to the key of the entity. The identifier is important for making a standard GET call to determine if the entity already exists, it provides the last part of the GET uri, for example `https://host.com/API/notifications/groups/NOTIFICATION-VX-99`. <br><br>Note that this setting is irrelevant if either `noGet` or `getUriExcludeIndentifier` are set to `true`.<br><br>A typical usecase for this is having an object being identified by a GUID but wanting to use a more speaking name for the entity key or utilize the ordering via suitable key names instead of using a non-speaking GUID.' |
102+
| `remove` | The entity will be DELETEd if it exists. If both `register` and `remove` is true, any found entity is first removed if it exists before it is being created.
103+
| `identifier` | Optional field to specify the objects 'identifier', if not set or empty the object 'identifier' will be set to the key of the entity. The identifier is important for making a standard GET call to determine if the entity already exists, it provides the last part of the GET uri, for example `https://host.com/API/notifications/groups/NOTIFICATION-VX-99`. <br><br>Note that this setting is irrelevant if either `noGet` or `getUriExcludeIndentifier` are set to `true`.<br><br>A typical usecase for this is having an object being identified by a GUID but wanting to use a more speaking name for the entity key or utilize the ordering via suitable key names instead of using a non-speaking GUID.' |
104+
| `deleteUriExcludeIdentifier` | Some APIs handle DELETEing of entities by calling DELETE to the parent resource and specifying the entity to delete in query params. If the subresource handles DELETEing in that way, set this parameter to `true` and provide the subresource `identifierQueryParam` to identify the entity. If `false` or unspecified, DELETE calls will be made to the path which ends with the entities identifier name.
104105
| `putUriExcludeIdentifier` | Some APIs handle PUTting of entities by PUTing to the parent resource and specifying the entity to create in the body. If the subresource handles PUTting in that way, set this parameter to `true`. If `false` or unspecified, PUT calls will be made to the path which ends with the entities name.
105106
| `putInsteadOfPost` | Some APIs use PUTting instead of POSTing for creation of new entities. If the subresource uses PUTting instead of POSTing, set this parameter to `true`.
106107
| `postQueryParams` | Query Parameters to add to the Url of a POST command. Not a frequent usa case but required to submit for example the `guid` of a UseCaseDefinition to migrate.

hull-vidispine-addon/hull-vidispine-addon.yaml

Lines changed: 59 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -116,20 +116,24 @@ hull:
116116
_DEFAULTS_:
117117
register: true
118118
putUriExcludeIdentifier: true
119+
deleteUriExcludeIdentifier: true
119120
20_clients:
120121
apiPath: "v1/Client"
121122
typeDescription: "Client"
122123
identifierQueryParam: "clientId"
123124
_DEFAULTS_:
124125
register: true
125126
putUriExcludeIdentifier: true
127+
deleteUriExcludeIdentifier: true
126128
30_roles:
127129
apiPath: "v1/Roles"
128130
typeDescription: "Roles"
129131
identifierQueryParam: "id"
130132
_DEFAULTS_:
131133
register: true
132134
remove: false
135+
putUriExcludeIdentifier: true
136+
deleteUriExcludeIdentifier: true
133137

134138
30_configportal:
135139
auth:
@@ -911,14 +915,11 @@ hull:
911915
912916
$contentType = "$(if ([String]::IsNullOrEmpty($value.contentType)) { "application/json" } else { $value.contentType })"
913917
$content = $value.config
914-
if ($value.remove -eq $true)
915-
{
916-
$content = [string]::empty
917-
}
918-
elseif ($contentType -eq "application/json")
918+
if ($contentType -eq "application/json")
919919
{
920920
$content = $content | ConvertTo-Json -Depth 20
921921
}
922+
922923
try {
923924
$callResult = $this.CheckEntity(
924925
"$($endpoint)/$($subresource.apiPath)",
@@ -938,7 +939,9 @@ hull:
938939
$contentType,
939940
$this.GetHttpHeaders($authSubresource, $contentType, $extraHeaders, $value),
940941
$value.getQueryParams,
941-
$value.customGetScriptJsonResponseConfigReplacements
942+
$value.customGetScriptJsonResponseConfigReplacements,
943+
$value.deleteUriExcludeIdentifier,
944+
$value.register -eq $true
942945
)
943946
944947
if (-Not ($this._successes))
@@ -994,13 +997,13 @@ hull:
994997
}
995998
996999
# Checks entities and performs required operations (DELETE/PUT/POST)
997-
hidden [PSCustomObject] CheckEntity([string] $apiEndpoint, [PSCustomObject] $identifier, [string] $content, [string] $entityType, [bool] $toBeDeleted, [string] $identifierQueryParam, [PSCustomObject] $auth, [bool] $putInsteadOfPost, [bool] $putUriExcludeIdentifier, [bool] $overwriteExisting, [PSCustomObject] $postQueryParams, [bool] $getUriExcludeIdentifier, [string] $getCustomScript, [bool] $noGet, [string] $contentType, [PSCustomObject] $headers, [PSCustomObject] $getQueryParams, [PSCustomObject] $customGetScriptJsonResponseConfigReplacements)
1000+
hidden [PSCustomObject] CheckEntity([string] $apiEndpoint, [PSCustomObject] $identifier, [string] $content, [string] $entityType, [bool] $toBeDeleted, [string] $identifierQueryParam, [PSCustomObject] $auth, [bool] $putInsteadOfPost, [bool] $putUriExcludeIdentifier, [bool] $overwriteExisting, [PSCustomObject] $postQueryParams, [bool] $getUriExcludeIdentifier, [string] $getCustomScript, [bool] $noGet, [string] $contentType, [PSCustomObject] $headers, [PSCustomObject] $getQueryParams, [PSCustomObject] $customGetScriptJsonResponseConfigReplacements, [bool] $deleteUriExcludeIdentifier, [bool] $register)
9981001
{
9991002
$apiEndpoint = $apiEndpoint.Trim('/')
10001003
$uri = "$apiEndpoint/$identifier"
10011004
$uriPut = if ($putUriExcludeIdentifier) { $apiEndpoint } else { $uri }
10021005
$uriGet = if ($getUriExcludeIdentifier) { $apiEndpoint } else { $uri }
1003-
$uriDelete = $uri
1006+
$uriDelete = if ($deleteUriExcludeIdentifier) { $apiEndpoint } else { $uri }
10041007
10051008
$message = ""
10061009
$statusCode = 500
@@ -1130,33 +1133,17 @@ hull:
11301133
}
11311134
}
11321135
$this.WriteLog("Content is '$($content)'")
1133-
if ($statusCode -eq 200)
1136+
1137+
if($toBeDeleted)
11341138
{
1135-
if($toBeDeleted) {
1139+
if ($statusCode -eq 200)
1140+
{
11361141
$this.WriteLog("**** '$entityType' entry '$identifier' already exists and is going to be deleted now")
11371142
$this.DeleteEntity($uriDelete, $identifier, $identifierQueryParam, $auth, $contentType, $headers)
11381143
$lastMethod = "DELETE"
11391144
$lastUri = $uriDelete
11401145
}
1141-
else
1142-
{
1143-
if ($overwriteExisting)
1144-
{
1145-
$this.WriteLog("**** '$entityType' entry '$identifier' already exists, hence PUTing instead of POSTing to update entity")
1146-
$this.PutEntity($uriPut, $content, $auth, $contentType, $headers)
1147-
$lastMethod = "PUT"
1148-
$lastUri = $uriPut
1149-
}
1150-
else
1151-
{
1152-
$this.WriteLog("**** '$entityType' entry '$identifier' already exists, not overwriting due to flag 'overwriteExisting' not being set")
1153-
}
1154-
}
1155-
1156-
}
1157-
elseif ($noGet -or ($statusCode -eq 404))
1158-
{
1159-
if($toBeDeleted)
1146+
elseif ($noGet -or ($statusCode -eq 404))
11601147
{
11611148
if($noGet)
11621149
{
@@ -1170,28 +1157,52 @@ hull:
11701157
$this.WriteLog("**** '$entityType' entry '$identifier' does not exist but should be deleted, nothing will be done")
11711158
}
11721159
}
1173-
else
1174-
{
1175-
$this.WriteLog("**** '$entityType' entry '$identifier' does not exist and will be created now")
1176-
if ($putInsteadOfPost)
1177-
{
1178-
$this.WriteLog("**** PUTting '$entityType' entry '$identifier' to create it since 'putInsteadOfPost' is set to true")
1179-
$this.PutEntity($uriPut, $content, $auth, $contentType, $headers)
1180-
$lastMethod = "PUT"
1181-
$lastUri = $uriPut
1182-
}
1183-
else
1184-
{
1185-
$this.WriteLog("**** POSTing '$entityType' entry '$identifier' to create it")
1186-
$this.PostEntity($apiEndpoint, $content, $auth, $postQueryParams, $contentType, $headers)
1187-
$lastMethod = "POST"
1188-
$lastUri = $apiEndpoint
1189-
}
1190-
}
1160+
$this.WriteLog("**** StatusCode is treated as 404 since entity does not exist!")
1161+
$statusCode = 404
1162+
}
1163+
1164+
if ($register)
1165+
{
1166+
if ($statusCode -eq 200)
1167+
{
1168+
if ($overwriteExisting)
1169+
{
1170+
$this.WriteLog("**** '$entityType' entry '$identifier' already exists, hence PUTing instead of POSTing to update entity")
1171+
$this.PutEntity($uriPut, $content, $auth, $contentType, $headers)
1172+
$lastMethod = "PUT"
1173+
$lastUri = $uriPut
1174+
}
1175+
else
1176+
{
1177+
$this.WriteLog("**** '$entityType' entry '$identifier' already exists, not overwriting due to flag 'overwriteExisting' not being set")
1178+
}
1179+
}
1180+
elseif ($noGet -or ($statusCode -eq 404))
1181+
{
1182+
$this.WriteLog("**** '$entityType' entry '$identifier' does not exist and will be created now")
1183+
if ($putInsteadOfPost)
1184+
{
1185+
$this.WriteLog("**** PUTting '$entityType' entry '$identifier' to create it since 'putInsteadOfPost' is set to true")
1186+
$this.PutEntity($uriPut, $content, $auth, $contentType, $headers)
1187+
$lastMethod = "PUT"
1188+
$lastUri = $uriPut
1189+
}
1190+
else
1191+
{
1192+
$this.WriteLog("**** POSTing '$entityType' entry '$identifier' to create it")
1193+
$this.PostEntity($apiEndpoint, $content, $auth, $postQueryParams, $contentType, $headers)
1194+
$lastMethod = "POST"
1195+
$lastUri = $apiEndpoint
1196+
}
1197+
}
1198+
else
1199+
{
1200+
throw [Exception]::new("ERROR --> Unexpected StatusCode: $($statusCode) - Message: $($message)")
1201+
}
11911202
}
11921203
else
11931204
{
1194-
throw [Exception]::new("ERROR --> Unexpected StatusCode: $($statusCode) - Message: $($message)")
1205+
$this.WriteLog("**** 'Register set to false, not PUTing or POSTing.")
11951206
}
11961207

11971208
return @{ "lastMethod" = $lastMethod; "lastUri" = $lastUri }

0 commit comments

Comments
 (0)