Package src :: Package com :: Package deviceatlas :: Package device :: Module config :: Class Config
[frames] | no frames]

Class Config

DeviceApi Configurations. To change the default configs of the DeviceAtlas DeviceApi create an instance of this class, set your preferred configs and pass the instance to the constructor of a DeviceApi.

Note that you may change the configs even after the Config instance has been passed to the DeviceApi.


Copyright: Copyright (c) DeviceAtlas Limited 2023. All Rights Reserved.

Author: DeviceAtlas Limited

Instance Methods
 
get_cookie_name(self)
Get the cookie name that the client side properties would be set to.
 
set_cookie_name(self, value)
To change the cookie name that the client side properties would be set to.
 
get_max_cache_entries(self)
Get the max number of results to be cached.
 
set_max_cache_entries(self, value)
Set the max number of results to be cached.
bool
is_cache_enabled(self)
Abstraction to make it easier to check if the cache is enabled on the DeviceApi instance.
Class Variables
  DEFAULT_COOKIE_NAME = 'DAPROPS'
  DEFAULT_MAX_CACHE_ENTRIES = 4096
Properties
  cookie_name
Get the cookie name that the client side properties would be set to.
  max_cache_entries
Get the max number of results to be cached.
Method Details

get_cookie_name(self)

 

Get the cookie name that the client side properties would be set to. When using get_properties(HEADERS), the detection would automatically use the contents of this cookie if it exists. If you want the client side properties to be used add the DeviceAtlas Client-side component (JS lib) to your web-site pages.

When the User-Agent or HTTP headers are set manually to get_properties() the client side properties (probably the value set to the cookie) can be manually passed to this methods as the second argument, note that this config is only used for get_properties(HEADERS).

set_cookie_name(self, value)

 

To change the cookie name that the client side properties would be set to. When using get_properties(HEADERS), the detection would automatically use the contents of this cookie if it exists. If you want the client side properties to be used add the DeviceAtlas Client-side component (JS lib) to your web-site pages.

When the User-Agent or HTTP headers are set manually to get_properties() the client side properties (probably the value set to the cookie) can be manually passed to this method as the second argument, note that this config is only used for get_properties(HEADERS). If you set the cookie-name to None then the client side properties cookie will be ignored.

Parameters:
  • value - The cookie name which the client side properties are set to. Set to None to turn off using the client side properties.

set_max_cache_entries(self, value)

 

Set the max number of results to be cached. Depending on the frequency and distance factor of your User-Agents or headers passed to the API for detection, increasing the result cache may increase performance by preventing repeated lookups. For a large set of inputs (i.e. an almost unique set of user-agents) set to lower numbers or zero to disable.

Parameters:
  • value - An integer greater than equal to zero.
Raises:
  • e - ValueError if value is not an integer greater than or equal to zero.

is_cache_enabled(self)

 

Abstraction to make it easier to check if the cache is enabled on the DeviceApi instance.

Returns: bool
True, if the max number of results to be cached is greater than zero; False, otherwise.

Property Details

cookie_name

Get the cookie name that the client side properties would be set to. When using get_properties(HEADERS), the detection would automatically use the contents of this cookie if it exists. If you want the client side properties to be used add the DeviceAtlas Client-side component (JS lib) to your web-site pages.

When the User-Agent or HTTP headers are set manually to get_properties() the client side properties (probably the value set to the cookie) can be manually passed to this methods as the second argument, note that this config is only used for get_properties(HEADERS).

Get Method:
get_cookie_name(self) - Get the cookie name that the client side properties would be set to.
Set Method:
set_cookie_name(self, value) - To change the cookie name that the client side properties would be set to.

max_cache_entries

Get the max number of results to be cached.

Get Method:
get_max_cache_entries(self) - Get the max number of results to be cached.
Set Method:
set_max_cache_entries(self, value) - Set the max number of results to be cached.