@@ -55,15 +55,15 @@ func main() {
5555 option.WithAPIKey (" My API Key" ), // defaults to os.LookupEnv("KERNEL_API_KEY")
5656 option.WithEnvironmentDevelopment (), // defaults to option.WithEnvironmentProduction()
5757 )
58- response , err := client.Apps .Deploy (context.TODO (), kernel.AppDeployParams {
59- EntrypointRelPath: " app.py " ,
58+ deployment , err := client.Apps .Deployments . New (context.TODO (), kernel.AppDeploymentNewParams {
59+ EntrypointRelPath: " main.ts " ,
6060 File: io.Reader (bytes.NewBuffer ([]byte (" REPLACE_ME" ))),
61- Version: kernel.String (" REPLACE_ME " ),
61+ Version: kernel.String (" 1.0.0 " ),
6262 })
6363 if err != nil {
6464 panic (err.Error ())
6565 }
66- fmt.Printf (" %+v \n " , response .Apps )
66+ fmt.Printf (" %+v \n " , deployment .Apps )
6767}
6868
6969```
@@ -269,7 +269,7 @@ client := kernel.NewClient(
269269 option.WithHeader (" X-Some-Header" , " custom_header_info" ),
270270)
271271
272- client.Apps . Deploy (context.TODO (), ...,
272+ client.Browsers . New (context.TODO (), ...,
273273 // Override the header
274274 option.WithHeader (" X-Some-Header" , " some_other_custom_header_info" ),
275275 // Add an undocumented field to the request body, using sjson syntax
@@ -298,18 +298,16 @@ When the API returns a non-success status code, we return an error with type
298298To handle errors, we recommend that you use the ` errors.As ` pattern:
299299
300300``` go
301- _ , err := client.Apps .Deploy (context.TODO (), kernel.AppDeployParams {
302- EntrypointRelPath : " app.py" ,
303- File : io.Reader (bytes.NewBuffer ([]byte (" REPLACE_ME" ))),
304- Version : kernel.String (" REPLACE_ME" ),
301+ _ , err := client.Browsers .New (context.TODO (), kernel.BrowserNewParams {
302+ InvocationID : " REPLACE_ME" ,
305303})
306304if err != nil {
307305 var apierr *kernel.Error
308306 if errors.As (err, &apierr) {
309307 println (string (apierr.DumpRequest (true ))) // Prints the serialized HTTP request
310308 println (string (apierr.DumpResponse (true ))) // Prints the serialized HTTP response
311309 }
312- panic (err.Error ()) // GET "/apps/deploy ": 400 Bad Request { ... }
310+ panic (err.Error ()) // GET "/browsers ": 400 Bad Request { ... }
313311}
314312```
315313
@@ -327,12 +325,10 @@ To set a per-retry timeout, use `option.WithRequestTimeout()`.
327325// This sets the timeout for the request, including all the retries.
328326ctx , cancel := context.WithTimeout (context.Background (), 5 *time.Minute )
329327defer cancel ()
330- client.Apps . Deploy (
328+ client.Browsers . New (
331329 ctx,
332- kernel.AppDeployParams {
333- EntrypointRelPath : " app.py" ,
334- File : io.Reader (bytes.NewBuffer ([]byte (" REPLACE_ME" ))),
335- Version : kernel.String (" REPLACE_ME" ),
330+ kernel.BrowserNewParams {
331+ InvocationID : " REPLACE_ME" ,
336332 },
337333 // This sets the per-retry timeout
338334 option.WithRequestTimeout (20 *time.Second ),
@@ -355,20 +351,20 @@ which can be used to wrap any `io.Reader` with the appropriate file name and con
355351``` go
356352// A file from the file system
357353file , err := os.Open (" /path/to/file" )
358- kernel.AppDeployParams {
359- EntrypointRelPath : " app.py" ,
354+ kernel.AppDeploymentNewParams {
355+ EntrypointRelPath : " src/ app.py" ,
360356 File : file,
361357}
362358
363359// A file from a string
364- kernel.AppDeployParams {
365- EntrypointRelPath : " app.py" ,
360+ kernel.AppDeploymentNewParams {
361+ EntrypointRelPath : " src/ app.py" ,
366362 File : strings.NewReader (" my file contents" ),
367363}
368364
369365// With a custom filename and contentType
370- kernel.AppDeployParams {
371- EntrypointRelPath : " app.py" ,
366+ kernel.AppDeploymentNewParams {
367+ EntrypointRelPath : " src/ app.py" ,
372368 File : kernel.File (strings.NewReader (` {"hello": "foo"}` ), " file.go" , " application/json" ),
373369}
374370```
@@ -388,12 +384,10 @@ client := kernel.NewClient(
388384)
389385
390386// Override per-request:
391- client.Apps . Deploy (
387+ client.Browsers . New (
392388 context.TODO (),
393- kernel.AppDeployParams {
394- EntrypointRelPath : " app.py" ,
395- File : io.Reader (bytes.NewBuffer ([]byte (" REPLACE_ME" ))),
396- Version : kernel.String (" REPLACE_ME" ),
389+ kernel.BrowserNewParams {
390+ InvocationID : " REPLACE_ME" ,
397391 },
398392 option.WithMaxRetries (5 ),
399393)
@@ -407,19 +401,17 @@ you need to examine response headers, status codes, or other details.
407401``` go
408402// Create a variable to store the HTTP response
409403var response *http.Response
410- response , err := client.Apps . Deploy (
404+ browser , err := client.Browsers . New (
411405 context.TODO (),
412- kernel.AppDeployParams {
413- EntrypointRelPath : " app.py" ,
414- File : io.Reader (bytes.NewBuffer ([]byte (" REPLACE_ME" ))),
415- Version : kernel.String (" REPLACE_ME" ),
406+ kernel.BrowserNewParams {
407+ InvocationID : " REPLACE_ME" ,
416408 },
417409 option.WithResponseInto (&response),
418410)
419411if err != nil {
420412 // handle error
421413}
422- fmt.Printf (" %+v \n " , response )
414+ fmt.Printf (" %+v \n " , browser )
423415
424416fmt.Printf (" Status Code: %d \n " , response.StatusCode )
425417fmt.Printf (" Headers: %+#v \n " , response.Header )
0 commit comments