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.

password: str = ''

Password.

type: str

Authorization type (only “basic” is supported).

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[OperationConfig] | 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_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. A preferred format is then chosen for each operation: PNG or JPEG for image requests, GML3, GML or XML for others.

Parameters:

operations_from_caps – Operations read from the capabilities.

get_capabilities()

Download the capabilities document of the service.

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. Adds a basic Authorization 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.

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

Bases: gws.Config

OWS operation that overrides or adds to those in the service capabilities.

formats: list[str] | None

Formats supported by the operation.

params: dict | None

Extra parameters added to GET requests for this operation.

postUrl: gws.Url | None

URL for POST requests.

url: gws.Url | None

URL for GET requests.

verb: gws.OwsVerb

OWS request type.