Skip to content

Commit

Permalink
Add hurl examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisguest75 committed Sep 3, 2023
1 parent 2ca8fdf commit 4af64f6
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 0 deletions.
1 change: 1 addition & 0 deletions 79_hurl/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hurl.vars
41 changes: 41 additions & 0 deletions 79_hurl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# HURL

Use hurl to test an API.

TODO:

* Is there a way to introduce delays in chained requests?
* Exporting captured values to environment variables

## Install

```sh
brew install hurl

hurl --help
```

## Run scripts

First you'll need to create the `hurl.vars` file from the template.

```sh
# Start a realtime.
hurl --very-verbose --test trint-realtime.hurl --variables-file ./hurl.vars



hurl --very-verbose --test trint-realtime-start.hurl --variables-file ./hurl.vars

hurl --very-verbose --test trint-realtime-status.hurl --variables-file ./hurl.vars --variable trintid=AIn0AosISr2G3u0gY-eP6Q

hurl --very-verbose --test trint-realtime-stop.hurl --variables-file ./hurl.vars --variable trintid=AIn0AosISr2G3u0gY-eP6Q


```

## Resources

* [hurl.dev](https://hurl.dev/)
* Orange-OpenSource/hurl repo [here](https://github.com/Orange-OpenSource/hurl)
* The Trint API Developer Hub [here](https://dev.trint.com/)
4 changes: 4 additions & 0 deletions 79_hurl/template.vars
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apikey=xxxxx
webapp=https://app.trint.com/
base_api=https://api.trint.com
base_upload_api=https://upload.trint.com
22 changes: 22 additions & 0 deletions 79_hurl/trint-realtime-start.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Start a realtime
PUT {{ base_api }}/transcripts/realtime
Accept: application/json
Content-Type: application/json
api-key: {{ apikey }}
{
"language": "en",
"streamUrl": "https://nhkwlive-xjp.akamaized.net/hls/live/2003458/nhkwlive-xjp-en/index_1M.m3u8",
"transcriptDelay":"5",
"title": "hurl test"
}

HTTP 200
[Captures]
trintid: jsonpath "$._id"

[Asserts]
header "Content-Type" == "application/json"
jsonpath "$._id" exists



16 changes: 16 additions & 0 deletions 79_hurl/trint-realtime-status.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Status for a realtime
GET {{ base_api }}/transcripts/realtime/{{trintid}}
Accept: application/json
Content-Type: application/json
api-key: {{ apikey }}

HTTP 200
[Asserts]
header "Content-Type" == "application/json"
jsonpath "$.status" exists
jsonpath "$.started" exists
jsonpath "$.expires" exists
jsonpath "$.status" == "TRANSCRIBING"



16 changes: 16 additions & 0 deletions 79_hurl/trint-realtime-stop.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Stop a realtime
DELETE {{ base_api }}/transcripts/realtime
Accept: application/json
Content-Type: application/json
api-key: {{ apikey }}
{
"trintId": "{{ trintid }}"
}

HTTP 200
[Asserts]
header "Content-Type" == "application/json"
#jsonpath "$[1].mime_type" == "video/mp4"



38 changes: 38 additions & 0 deletions 79_hurl/trint-realtime.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
##############################################################
## Start a realtime
##############################################################
PUT {{ base_api }}/transcripts/realtime
Accept: application/json
Content-Type: application/json
api-key: {{ apikey }}
{
"language": "en",
"streamUrl": "https://nhkwlive-xjp.akamaized.net/hls/live/2003458/nhkwlive-xjp-en/index_1M.m3u8",
"transcriptDelay":"5",
"title": "hurl test"
}

HTTP 200
[Captures]
trintid: jsonpath "$._id"
[Asserts]
header "Content-Type" == "application/json"

##############################################################
## Status realtime
##############################################################

# Status for a realtime
GET {{ base_api }}/transcripts/realtime/{{ trintid }}
Accept: application/json
Content-Type: application/json
api-key: {{ apikey }}

HTTP 200
[Asserts]
header "Content-Type" == "application/json"
jsonpath "$.status" exists
jsonpath "$.started" exists
jsonpath "$.expires" exists
jsonpath "$.status" == "TRANSCRIBING"

0 comments on commit 4af64f6

Please sign in to comment.