fix: barentswatch token decoding that should not have worked the first time

Move large json payload comment to its own doc file. Finally make
barentswatch keys optional
This commit is contained in:
Simen Kirkvik
2023-12-13 08:58:34 +01:00
parent 8872789ef7
commit 08f7d3e305
7 changed files with 469 additions and 449 deletions

View File

@@ -0,0 +1,438 @@
{
"ilaSurveillanceZones": [
{
"id": 3,
"forskNr": "FOR-2016-06-01-557",
"forskNavn": "string",
"forskLink": "https://lovdata.no/dokument/FV/forskrift/2016-06-01-557",
"sistEndret": "2016-07-01T00:00:00.000Z",
"fromDate": "2016-06-01T00:00:00.000Z",
"toDate": "",
"originalDate": "",
"localities": [
{
"localityNo": 12345,
"name": "Dragsundet",
"isReportingLocality": true,
"ilaSuspected": true,
"ilaConfirmed": true,
"position": {
"type": "Point",
"coordinates": [
10.4,
60.5
]
}
}
],
"geometry": {
"type": "Point",
"coordinates": [
10.4,
60.5
]
}
}
],
"ilaProtectionZones": [
{
"id": 3,
"forskNr": "FOR-2016-06-01-557",
"forskNavn": "string",
"forskLink": "https://lovdata.no/dokument/FV/forskrift/2016-06-01-557",
"sistEndret": "2016-07-01T00:00:00.000Z",
"fromDate": "2016-06-01T00:00:00.000Z",
"toDate": "",
"originalDate": "",
"localities": [
{
"localityNo": 12345,
"name": "Dragsundet",
"isReportingLocality": true,
"ilaSuspected": true,
"ilaConfirmed": true,
"position": {
"type": "Point",
"coordinates": [
10.4,
60.5
]
}
}
],
"geometry": {
"type": "Point",
"coordinates": [
10.4,
60.5
]
}
}
],
"pdSurveillanceZones": [
{
"id": 3,
"forskNr": "FOR-2016-02-10-116",
"forskNavn": "Forskrift om kontrollområde for ...",
"forskLink": "https://lovdata.no/dokument/FV/forskrift/2016-02-10-116",
"sistEndret": "2016-07-01T00:00:00.000Z",
"fromDate": "2016-02-10T00:00:00.000Z",
"toDate": "2023-12-11T15:07:32.852Z",
"originalDate": "2023-12-11T15:07:32.852Z",
"localities": [
{
"localityNo": 12345,
"name": "Dragsundet",
"isReportingLocality": true,
"pdSuspected": true,
"pdConfirmed": true
}
],
"geometry": {
"type": "Point",
"coordinates": [
10.4,
60.5
]
}
}
],
"pdProtectionZones": [
{
"id": 3,
"forskNr": "FOR-2016-02-10-116",
"forskNavn": "Forskrift om kontrollområde for ...",
"forskLink": "https://lovdata.no/dokument/FV/forskrift/2016-02-10-116",
"sistEndret": "2016-07-01T00:00:00.000Z",
"fromDate": "2016-02-10T00:00:00.000Z",
"toDate": "2023-12-11T15:07:32.852Z",
"originalDate": "2023-12-11T15:07:32.852Z",
"localities": [
{
"localityNo": 12345,
"name": "Dragsundet",
"isReportingLocality": true,
"pdSuspected": true,
"pdConfirmed": true
}
],
"geometry": {
"type": "Point",
"coordinates": [
10.4,
60.5
]
}
}
],
"localityName": "Flaberg",
"localityWeek": {
"id": 123456,
"localityNo": 12345,
"year": 2016,
"week": 25,
"hasReportedLice": true,
"hasMechanicalRemoval": true,
"hasBathTreatment": true,
"hasInFeedTreatment": true,
"hasCleanerFishDeployed": true,
"isFallow": true,
"avgAdultFemaleLice": 0.33,
"avgMobileLice": 1.11,
"avgStationaryLice": 0.21,
"seaTemperature": 8.5,
"bathTreatments": [
{
"id": 11111,
"treatmentType": "Bath",
"startDate": "2016-05-25T00:00:00.000Z",
"endDate": "2016-05-30T00:00:00.000Z",
"entireLocality": true,
"treatmentDetail": [
{
"id": 1111112,
"quantity": 1,
"concentration": 0.1,
"substanceId": 0,
"substance": {
"id": 1,
"name": "Deltamethrin"
}
}
]
}
],
"inFeedTreatments": [
{
"id": 11111,
"treatmentType": "Bath",
"startDate": "2016-05-25T00:00:00.000Z",
"endDate": "2016-05-30T00:00:00.000Z",
"entireLocality": true,
"treatmentDetail": [
{
"id": 1111112,
"quantity": 1,
"concentration": 0.1,
"substanceId": 0,
"substance": {
"id": 1,
"name": "Deltamethrin"
}
}
]
}
],
"cleanerFish": {
"id": 111116,
"entireLocality": true,
"cleanerFishDetail": [
{
"id": 11117,
"speciesId": 222221,
"species": {
"id": 11118,
"name": "Rognkjeks (hun)"
},
"quantity": 9009
}
]
},
"mechanicalRemoval": {
"id": 0,
"entireLocality": true,
"method": "string"
},
"timeSinceLastChitinSynthesisInhibitorTreatment": "string",
"hasSalmonoids": true,
"isSlaughterHoldingCage": true
},
"ilaPd": [
{
"id": 111120,
"localityNo": 12345,
"disease": "PD",
"ruling": "Påvist",
"fromDate": "2019-11-29T00:00:00",
"toDate": ""
}
],
"ilaPdCase": [
{
"id": "string",
"localityNo": 0,
"disease": "Unknown",
"subtype": "gHPR0_ILAV",
"disproved": true,
"suspectedDate": "2023-12-11T15:07:32.852Z",
"confirmedDate": "2023-12-11T15:07:32.852Z",
"emptiedDate": "2023-12-11T15:07:32.852Z",
"closedDate": "2023-12-11T15:07:32.852Z",
"disprovedDate": "2023-12-11T15:07:32.852Z",
"createdDate": "2023-12-11T15:07:32.852Z",
"changedDate": "2023-12-11T15:07:32.852Z"
}
],
"aquaCultureRegister": {
"localityNo": 12345,
"name": "Skodjefjorden",
"municipalityNo": "1213",
"municipality": "Skodje",
"placement": "SJØ",
"capacity": 6240,
"unit": "TN",
"purposes": "Kommersiell",
"productionTypes": "Matfisk",
"species": "Laks, Ørret, Regnbueørret",
"speciesList": [
"string"
],
"isGreen": true,
"lon": 26.691334,
"lat": 70.408,
"aquaCultureUpdateTime": "2016-05-30T00:00:00.000Z",
"organizations": [
{
"name": "Fjordlaks AS",
"organizationNo": "123456789",
"address": "Fjordgata 66",
"postalCode": "6005",
"city": "Ålesund",
"localities": [
{
"localityNo": 0,
"name": "string",
"municipality": "string",
"isReportingLocality": true
}
]
}
],
"licenses": [
{
"licenseNo": "XXXX0001",
"purpose": "Kommersiell",
"productionType": "Matfisk",
"grantDate": "1973-12-04T00:00:00.000Z",
"expirationDate": "2023-12-11T15:07:32.852Z",
"isGreen": true,
"localities": [
{
"localityNo": 0,
"name": "string",
"municipality": "string",
"isReportingLocality": true
}
],
"licensee": "LAKSEFIRMA AS",
"species": [
"string"
],
"capacity": 780,
"unit": "TN"
}
]
},
"localityIsInAquaCultureRegister": true,
"ilaFreeAreas": [
{
"areaId": 10,
"areaName": "Femangervågen",
"version": 1,
"descriptionNo": "En sone i Fusa kommune, Hordaland som er omfattet av Regine enhet 053.7Z, og omfatter lokalitet nr. 12112 Femangervågen.",
"descriptionEn": "A zone in the municipality of Fusa, Hordaland, which is covered by the water catchment area 053.7Z, and includes site no. 12112 Femangervågen.",
"regulationUrl": "https://lovdata.no/dokument/SF/forskrift/2008-06-17-819#KAPITTEL_5",
"validFrom": "2019-06-01T00:00:00+02:00",
"validTo": "2023-12-11T15:07:32.852Z",
"category": "Kategori 1",
"areaParts": [
{
"areaId": 10,
"version": 1,
"polygonId": 9,
"geom": [
{
"type": "Point",
"coordinates": [
10.4,
60.5
]
},
{
"type": "LineString",
"coordinates": [
[
10.4,
60.5
],
[
10.4,
60.5
]
]
},
{
"type": "Polygon",
"coordinates": [
[
[
10.4,
60.5
]
],
[
[
10.4,
60.5
]
],
[
[
10.4,
60.5
]
],
[
[
10.4,
60.5
]
]
]
}
],
"areaType": "land"
}
]
}
],
"productionArea": {
"id": 3,
"name": "Karmøy til Sotra",
"geometry": {
"type": "Point",
"coordinates": [
10.4,
60.5
]
},
"colors": [
{
"color": "green",
"fromDate": "2023-12-11T15:07:32.852Z",
"toDate": "2023-12-11T15:07:32.852Z"
}
]
},
"pdZoneId": "string",
"escapes": [
{
"date": "2016-06-21T00:00:00.000Z",
"comment": "string",
"species": "Laks",
"count": 1,
"countType": "estimert #",
"countCategory": "20-999",
"size": 4000,
"localityNo": 12345,
"localityName": "STORFJORDEN",
"year": 2016,
"week": 25,
"objectId": 12345,
"parentId": 1234,
"localityCapacity": 150,
"waterEnvironmentCode": "Salt",
"waterEnvironment": "SALTVANN",
"status": "Del 2",
"statusLocality": "KLARERT",
"createdDate": "2016-06-21T00:00:00.000Z",
"lastEditedDate": "2016-06-21T00:00:00.000Z",
"globalId": "{22CA7E34-EBD0-4204-A65E-030252D047DF}",
"cleanerFish": true,
"recaptureStarted": true,
"recaptureDescription": "Havn er sperret med gjennfangst garn",
"recapturesCompleted": 1,
"countEstimated": "1-19",
"municipalityNumber": 5421,
"countyCode": 54,
"county": "Trøndelag",
"description": "Fisk falt i havet ved håving",
"sizeEstimated": 5500
}
],
"liceCountPreviousWeek": {
"year": 2016,
"week": 25,
"hasReportedLice": true,
"avgAdultFemaleLice": 0.03,
"avgMobileLice": 0.04,
"avgStationaryLice": 0.01
},
"exportRestrictionAreas": [
{
"localityNo": 0,
"year": 0,
"week": 0
}
]
}

View File

@@ -13,6 +13,7 @@
secretKeyRef:
name: production-atlantis-barentswatch
key: secret
optional: true
- op: add
path: /spec/template/spec/containers/0/env/-
value:
@@ -20,4 +21,5 @@
valueFrom:
secretKeyRef:
name: production-atlantis-barentswatch
key: client-id
key: client-id
optional: true

View File

@@ -17,7 +17,8 @@
valueFrom:
secretKeyRef:
name: x-review-atlantis-barentswatch
key: api-secret
key: secret
optional: true
- op: add
path: /spec/template/spec/containers/0/env/-
value:
@@ -26,6 +27,7 @@
secretKeyRef:
name: x-review-atlantis-barentswatch
key: client-id
optional: true
# - op: add
# path: /spec/template/spec/containers/-
# value:

View File

@@ -18,6 +18,7 @@
secretKeyRef:
name: staging-atlantis-barentswatch
key: secret
optional: true
- op: add
path: /spec/template/spec/containers/0/env/-
value:
@@ -25,4 +26,5 @@
valueFrom:
secretKeyRef:
name: staging-atlantis-barentswatch
key: client-id
key: client-id
optional: true

View File

@@ -1170,446 +1170,7 @@ let aquaculturePopup =
</sp-card>
"""
// Example payload from BarentsWatch
// {
// "ilaSurveillanceZones": [
// {
// "id": 3,
// "forskNr": "FOR-2016-06-01-557",
// "forskNavn": "string",
// "forskLink": "https://lovdata.no/dokument/FV/forskrift/2016-06-01-557",
// "sistEndret": "2016-07-01T00:00:00.000Z",
// "fromDate": "2016-06-01T00:00:00.000Z",
// "toDate": "",
// "originalDate": "",
// "localities": [
// {
// "localityNo": 12345,
// "name": "Dragsundet",
// "isReportingLocality": true,
// "ilaSuspected": true,
// "ilaConfirmed": true,
// "position": {
// "type": "Point",
// "coordinates": [
// 10.4,
// 60.5
// ]
// }
// }
// ],
// "geometry": {
// "type": "Point",
// "coordinates": [
// 10.4,
// 60.5
// ]
// }
// }
// ],
// "ilaProtectionZones": [
// {
// "id": 3,
// "forskNr": "FOR-2016-06-01-557",
// "forskNavn": "string",
// "forskLink": "https://lovdata.no/dokument/FV/forskrift/2016-06-01-557",
// "sistEndret": "2016-07-01T00:00:00.000Z",
// "fromDate": "2016-06-01T00:00:00.000Z",
// "toDate": "",
// "originalDate": "",
// "localities": [
// {
// "localityNo": 12345,
// "name": "Dragsundet",
// "isReportingLocality": true,
// "ilaSuspected": true,
// "ilaConfirmed": true,
// "position": {
// "type": "Point",
// "coordinates": [
// 10.4,
// 60.5
// ]
// }
// }
// ],
// "geometry": {
// "type": "Point",
// "coordinates": [
// 10.4,
// 60.5
// ]
// }
// }
// ],
// "pdSurveillanceZones": [
// {
// "id": 3,
// "forskNr": "FOR-2016-02-10-116",
// "forskNavn": "Forskrift om kontrollområde for ...",
// "forskLink": "https://lovdata.no/dokument/FV/forskrift/2016-02-10-116",
// "sistEndret": "2016-07-01T00:00:00.000Z",
// "fromDate": "2016-02-10T00:00:00.000Z",
// "toDate": "2023-12-11T15:07:32.852Z",
// "originalDate": "2023-12-11T15:07:32.852Z",
// "localities": [
// {
// "localityNo": 12345,
// "name": "Dragsundet",
// "isReportingLocality": true,
// "pdSuspected": true,
// "pdConfirmed": true
// }
// ],
// "geometry": {
// "type": "Point",
// "coordinates": [
// 10.4,
// 60.5
// ]
// }
// }
// ],
// "pdProtectionZones": [
// {
// "id": 3,
// "forskNr": "FOR-2016-02-10-116",
// "forskNavn": "Forskrift om kontrollområde for ...",
// "forskLink": "https://lovdata.no/dokument/FV/forskrift/2016-02-10-116",
// "sistEndret": "2016-07-01T00:00:00.000Z",
// "fromDate": "2016-02-10T00:00:00.000Z",
// "toDate": "2023-12-11T15:07:32.852Z",
// "originalDate": "2023-12-11T15:07:32.852Z",
// "localities": [
// {
// "localityNo": 12345,
// "name": "Dragsundet",
// "isReportingLocality": true,
// "pdSuspected": true,
// "pdConfirmed": true
// }
// ],
// "geometry": {
// "type": "Point",
// "coordinates": [
// 10.4,
// 60.5
// ]
// }
// }
// ],
// "localityName": "Flaberg",
// "localityWeek": {
// "id": 123456,
// "localityNo": 12345,
// "year": 2016,
// "week": 25,
// "hasReportedLice": true,
// "hasMechanicalRemoval": true,
// "hasBathTreatment": true,
// "hasInFeedTreatment": true,
// "hasCleanerFishDeployed": true,
// "isFallow": true,
// "avgAdultFemaleLice": 0.33,
// "avgMobileLice": 1.11,
// "avgStationaryLice": 0.21,
// "seaTemperature": 8.5,
// "bathTreatments": [
// {
// "id": 11111,
// "treatmentType": "Bath",
// "startDate": "2016-05-25T00:00:00.000Z",
// "endDate": "2016-05-30T00:00:00.000Z",
// "entireLocality": true,
// "treatmentDetail": [
// {
// "id": 1111112,
// "quantity": 1,
// "concentration": 0.1,
// "substanceId": 0,
// "substance": {
// "id": 1,
// "name": "Deltamethrin"
// }
// }
// ]
// }
// ],
// "inFeedTreatments": [
// {
// "id": 11111,
// "treatmentType": "Bath",
// "startDate": "2016-05-25T00:00:00.000Z",
// "endDate": "2016-05-30T00:00:00.000Z",
// "entireLocality": true,
// "treatmentDetail": [
// {
// "id": 1111112,
// "quantity": 1,
// "concentration": 0.1,
// "substanceId": 0,
// "substance": {
// "id": 1,
// "name": "Deltamethrin"
// }
// }
// ]
// }
// ],
// "cleanerFish": {
// "id": 111116,
// "entireLocality": true,
// "cleanerFishDetail": [
// {
// "id": 11117,
// "speciesId": 222221,
// "species": {
// "id": 11118,
// "name": "Rognkjeks (hun)"
// },
// "quantity": 9009
// }
// ]
// },
// "mechanicalRemoval": {
// "id": 0,
// "entireLocality": true,
// "method": "string"
// },
// "timeSinceLastChitinSynthesisInhibitorTreatment": "string",
// "hasSalmonoids": true,
// "isSlaughterHoldingCage": true
// },
// "ilaPd": [
// {
// "id": 111120,
// "localityNo": 12345,
// "disease": "PD",
// "ruling": "Påvist",
// "fromDate": "2019-11-29T00:00:00",
// "toDate": ""
// }
// ],
// "ilaPdCase": [
// {
// "id": "string",
// "localityNo": 0,
// "disease": "Unknown",
// "subtype": "gHPR0_ILAV",
// "disproved": true,
// "suspectedDate": "2023-12-11T15:07:32.852Z",
// "confirmedDate": "2023-12-11T15:07:32.852Z",
// "emptiedDate": "2023-12-11T15:07:32.852Z",
// "closedDate": "2023-12-11T15:07:32.852Z",
// "disprovedDate": "2023-12-11T15:07:32.852Z",
// "createdDate": "2023-12-11T15:07:32.852Z",
// "changedDate": "2023-12-11T15:07:32.852Z"
// }
// ],
// "aquaCultureRegister": {
// "localityNo": 12345,
// "name": "Skodjefjorden",
// "municipalityNo": "1213",
// "municipality": "Skodje",
// "placement": "SJØ",
// "capacity": 6240,
// "unit": "TN",
// "purposes": "Kommersiell",
// "productionTypes": "Matfisk",
// "species": "Laks, Ørret, Regnbueørret",
// "speciesList": [
// "string"
// ],
// "isGreen": true,
// "lon": 26.691334,
// "lat": 70.408,
// "aquaCultureUpdateTime": "2016-05-30T00:00:00.000Z",
// "organizations": [
// {
// "name": "Fjordlaks AS",
// "organizationNo": "123456789",
// "address": "Fjordgata 66",
// "postalCode": "6005",
// "city": "Ålesund",
// "localities": [
// {
// "localityNo": 0,
// "name": "string",
// "municipality": "string",
// "isReportingLocality": true
// }
// ]
// }
// ],
// "licenses": [
// {
// "licenseNo": "XXXX0001",
// "purpose": "Kommersiell",
// "productionType": "Matfisk",
// "grantDate": "1973-12-04T00:00:00.000Z",
// "expirationDate": "2023-12-11T15:07:32.852Z",
// "isGreen": true,
// "localities": [
// {
// "localityNo": 0,
// "name": "string",
// "municipality": "string",
// "isReportingLocality": true
// }
// ],
// "licensee": "LAKSEFIRMA AS",
// "species": [
// "string"
// ],
// "capacity": 780,
// "unit": "TN"
// }
// ]
// },
// "localityIsInAquaCultureRegister": true,
// "ilaFreeAreas": [
// {
// "areaId": 10,
// "areaName": "Femangervågen",
// "version": 1,
// "descriptionNo": "En sone i Fusa kommune, Hordaland som er omfattet av Regine enhet 053.7Z, og omfatter lokalitet nr. 12112 Femangervågen.",
// "descriptionEn": "A zone in the municipality of Fusa, Hordaland, which is covered by the water catchment area 053.7Z, and includes site no. 12112 Femangervågen.",
// "regulationUrl": "https://lovdata.no/dokument/SF/forskrift/2008-06-17-819#KAPITTEL_5",
// "validFrom": "2019-06-01T00:00:00+02:00",
// "validTo": "2023-12-11T15:07:32.852Z",
// "category": "Kategori 1",
// "areaParts": [
// {
// "areaId": 10,
// "version": 1,
// "polygonId": 9,
// "geom": [
// {
// "type": "Point",
// "coordinates": [
// 10.4,
// 60.5
// ]
// },
// {
// "type": "LineString",
// "coordinates": [
// [
// 10.4,
// 60.5
// ],
// [
// 10.4,
// 60.5
// ]
// ]
// },
// {
// "type": "Polygon",
// "coordinates": [
// [
// [
// 10.4,
// 60.5
// ]
// ],
// [
// [
// 10.4,
// 60.5
// ]
// ],
// [
// [
// 10.4,
// 60.5
// ]
// ],
// [
// [
// 10.4,
// 60.5
// ]
// ]
// ]
// }
// ],
// "areaType": "land"
// }
// ]
// }
// ],
// "productionArea": {
// "id": 3,
// "name": "Karmøy til Sotra",
// "geometry": {
// "type": "Point",
// "coordinates": [
// 10.4,
// 60.5
// ]
// },
// "colors": [
// {
// "color": "green",
// "fromDate": "2023-12-11T15:07:32.852Z",
// "toDate": "2023-12-11T15:07:32.852Z"
// }
// ]
// },
// "pdZoneId": "string",
// "escapes": [
// {
// "date": "2016-06-21T00:00:00.000Z",
// "comment": "string",
// "species": "Laks",
// "count": 1,
// "countType": "estimert #",
// "countCategory": "20-999",
// "size": 4000,
// "localityNo": 12345,
// "localityName": "STORFJORDEN",
// "year": 2016,
// "week": 25,
// "objectId": 12345,
// "parentId": 1234,
// "localityCapacity": 150,
// "waterEnvironmentCode": "Salt",
// "waterEnvironment": "SALTVANN",
// "status": "Del 2",
// "statusLocality": "KLARERT",
// "createdDate": "2016-06-21T00:00:00.000Z",
// "lastEditedDate": "2016-06-21T00:00:00.000Z",
// "globalId": "{22CA7E34-EBD0-4204-A65E-030252D047DF}",
// "cleanerFish": true,
// "recaptureStarted": true,
// "recaptureDescription": "Havn er sperret med gjennfangst garn",
// "recapturesCompleted": 1,
// "countEstimated": "1-19",
// "municipalityNumber": 5421,
// "countyCode": 54,
// "county": "Trøndelag",
// "description": "Fisk falt i havet ved håving",
// "sizeEstimated": 5500
// }
// ],
// "liceCountPreviousWeek": {
// "year": 2016,
// "week": 25,
// "hasReportedLice": true,
// "avgAdultFemaleLice": 0.03,
// "avgMobileLice": 0.04,
// "avgStationaryLice": 0.01
// },
// "exportRestrictionAreas": [
// {
// "localityNo": 0,
// "year": 0,
// "week": 0
// }
// ]
// }
// See docs/barentswatch-fishhealth-example-payload.json
type BarentsWatchFishHealth = {
LocalityName : string
LocalityIsInAquaCultureRegister : bool
@@ -1631,7 +1192,7 @@ type BarentsWatchFishHealth = {
with
static member decoder =
Decode.Auto.generateDecoder<BarentsWatchFishHealth>(
caseStrategy = CaseStrategy.CamelCase
caseStrategy = CaseStrategy.PascalCase
)
let fetchBarentsWatchFishHealth year week localityId callback =

View File

@@ -168,9 +168,14 @@ module Handlers =
with e ->
Log.Error("Exception while fetching value from redis: {Message}", e.Message)
RedisValue()
Log.Debug("Got value from redis {@Value}", value)
if value.HasValue then
let token = value.Box |> tryUnbox<BarentsWatchToken>
let tokenStr = string value
Log.Debug("Value is {Value}", tokenStr)
let token =
tokenStr
|> BarentsWatchToken.decode
|> Result.toOption
Log.Debug("Token is {@Token}", token)
return token
else
let! tokenRes =
@@ -189,10 +194,9 @@ module Handlers =
Log.Error(err)
return None
| Ok token ->
let tokenStr = Encode.Auto.toString(value = token, caseStrategy = CaseStrategy.SnakeCase)
let newValue = RedisValue(tokenStr)
let tokenStr = BarentsWatchToken.encode token
let expire = TimeSpan.FromSeconds token.ExpiresIn
if db.StringSet(key = key, value = newValue, expiry = expire) then
if db.StringSet(key = key, value = tokenStr, expiry = expire) then
Log.Debug("Updated barentsWatch token")
else
Log.Error("Error pushing barentsWatch token to Redis")

View File

@@ -25,6 +25,17 @@ type BarentsWatchToken = {
TokenType: string
Scope: string
}
with
static member decode (str: string) : Result<BarentsWatchToken, string> =
Thoth.Json.Net.Decode.Auto.fromString<BarentsWatchToken>(
json = str,
caseStrategy = Thoth.Json.Net.CaseStrategy.SnakeCase
)
static member encode (token: BarentsWatchToken) : string =
Thoth.Json.Net.Encode.Auto.toString(
value = token,
caseStrategy = Thoth.Json.Net.CaseStrategy.SnakeCase
)
[<RequireQualifiedAccess>]
module Api =