Share via


CognitiveServiceRestClient Class

REST client to access Cognitive Service Language REST endpoints. Authentication tokens are not required.

Experimental: This class is experimental and may change in future versions.

Constructor

CognitiveServiceRestClient(token_provider: TokenProvider | None = None, retry_config: Dict | None = None)

Parameters

Name Description
token_provider
<xref:sempy.fabric.TokenProvider>

Implementation of TokenProvider that can provide auth token for access to the PowerBI workspace. Will attempt to acquire token from its execution environment if not provided.

Default value: None
retry_config

Configuration for the retry strategy. The following keys are filled with default values if not provided:

  • total: int, default=10
  • allowed_methods: list, default=["HEAD", "GET", "POST", "PUT", "PATCH", "DELETE"]
  • status_forcelist: list, default=[429, 502, 503, 504]
  • backoff_factor: int, default=1
  • raise_on_status: bool, default=False
Default value: None

Methods

request

Request to the Cognitive Service REST API.

request

Request to the Cognitive Service REST API.

request(method: str, path_or_url: str, auth_required: bool = True, *args, **kwargs)

Parameters

Name Description
method
Required
str

HTTP method.

path_or_url
Required
str

The path or the url to the resource.

auth_required

If True, authentication is required.

Default value: True
*args
Required

Arguments passed to the request method.

**kwargs
Required

Arguments passed to the request method.

Returns

Type Description

The response from the REST API.