gws.base.ows.client.provider

Base OWS service provider.

Source code: gws.base.ows.client.provider

Module Contents

class gws.base.ows.client.provider.AuthorizationConfig(*args, **kwargs)

Bases: gws.Config

Credentials for accessing the service.

header: str = 'Authorization'

HTTP header that carries the token.

password: str = ''

Password.

prefix: str = ''

Prefix expected before the token in the header value.

token: str = ''

Authorization token.

type: str

Authorization type (“basic” or “token”).

username: str = ''

User name.

class gws.base.ows.client.provider.Config(*args, **kwargs)

Bases: gws.Config

OWS provider configuration.

alwaysXY: bool = False

Force XY axis order for CRSs with lat/lon axis order.

authorization: AuthorizationConfig | None

Service authorization options.

capsCacheMaxAge: gws.Duration = '1d'

How long a downloaded capabilities document is cached.

forceCrs: gws.CrsName | None

Use this CRS for requests.

maxRequests: int = 0

Max. concurrent requests to this source.

operations: list[gws.base.ows.client.operation.Config] | None

Override operations reported in capabilities.

url: gws.Url

Service URL.

class gws.base.ows.client.provider.Object

Bases: gws.OwsServiceProvider

Base OWS service provider.

Holds the service URL, version, operations and source layers of a remote OWS service, and prepares request arguments for its operations. Provides subclasses with capabilities download and caching, merging of configured and reported operations and format selection. Protocol-specific subclasses set protocol and parse the capabilities.

cache_hash()

Compute a hash of the provider settings, used to build cache keys.

Returns:

A hash of the URL, the forced CRS and the axis order setting.

configure()

Configuration hook.

Called when the node is initialized. Raising an exception here aborts the creation of the node.

configure_authorization()
configure_operations(operations_from_caps)

Set up the provider operations.

Operations from the configuration replace those from the capabilities with the same verb; attributes missing in the configuration are taken from the capabilities (see operation.create).

Parameters:

operations_from_caps – Operations read from the capabilities.

get_capabilities()

Download the capabilities document of the service.

The request goes to the service URL, unless the configuration has a GetCapabilities operation with its own attributes. The document is cached for capsCacheMaxAge.

Returns:

The capabilities XML text.

Raises:

gws.ExternalServiceError – If the request fails.

get_operation(verb, method=None)

Find an operation by its verb.

Parameters:
  • verb – Request type.

  • method – Request method. For POST, the operation must have a POST URL, otherwise a GET URL.

Returns:

The operation, or None if the service does not support it.

prepare_operation(op: gws.OwsOperation, method: gws.RequestMethod = None, params=None) → gws.base.ows.client.request.Args

Prepare the request arguments for an operation.

For GET requests, the operation parameters are included. Parameter names are upper-cased and checked against the operation’s allowed values. MIME types in FORMAT, INFO_FORMAT and OUTPUTFORMAT are sent in the spelling of the service. Adds a basic Authorization header or a token header if configured.

Parameters:
  • op – Operation.

  • method – Request method, GET by default.

  • params – Request parameters.

Returns:

Request arguments, to be passed to request.get.

Raises:

gws.Error – If a parameter value is not allowed by the operation.