@@ -529,26 +529,58 @@ All operations return a response object or raise an exception:
529
529
### Example
530
530
531
531
``` python
532
- from glean import Glean, errors
532
+ from glean import Glean, errors, models
533
533
import os
534
534
535
535
536
536
with Glean(
537
537
bearer_auth = os.getenv(" GLEAN_BEARER_AUTH" , " " ),
538
- server_url = os.getenv(" GLEAN_SERVER_URL" , " https://customer-be.glean.com" )
539
- ) as glean:
538
+ ) as g_client:
540
539
try :
541
- res = glean.chat.ask()
540
+ res = g_client.client.search.execute(search_request = models.SearchRequest(
541
+ tracking_token = " trackingToken" ,
542
+ page_size = 10 ,
543
+ query = " vacation policy" ,
544
+ request_options = models.SearchRequestOptions(
545
+ facet_filters = [
546
+ models.FacetFilter(
547
+ field_name = " type" ,
548
+ values = [
549
+ models.FacetFilterValue(
550
+ value = " article" ,
551
+ relation_type = models.RelationType.EQUALS ,
552
+ ),
553
+ models.FacetFilterValue(
554
+ value = " document" ,
555
+ relation_type = models.RelationType.EQUALS ,
556
+ ),
557
+ ],
558
+ ),
559
+ models.FacetFilter(
560
+ field_name = " department" ,
561
+ values = [
562
+ models.FacetFilterValue(
563
+ value = " engineering" ,
564
+ relation_type = models.RelationType.EQUALS ,
565
+ ),
566
+ ],
567
+ ),
568
+ ],
569
+ facet_bucket_size = 246815 ,
570
+ ),
571
+ ))
572
+
573
+ # Handle response
542
574
print (res)
543
- # If the server returned structured data
544
- except errors.GleanDataError as e:
545
- print (e.data)
546
- print (e.data.errorMessage)
547
575
except errors.GleanError as e:
548
576
print (e.message)
549
577
print (e.status_code)
550
578
print (e.raw_response)
551
579
print (e.body)
580
+ # If the server returned structured data
581
+ except errors.GleanDataError as e:
582
+ print (e.data)
583
+ print (e.data.errorMessage)
552
584
```
553
585
554
586
By default, an API error will raise a errors.GleanError exception, which has the following properties:
0 commit comments