colda.network package

Submodules

colda.network.api module

class colda.network.api.DP

Bases: object

Data processing Parse http response

Methods

load_network_response

classmethod check_network_response(network_response: Dict[str, Any] | List[Any], status_code: int = 200) None

Check status_code of network response

Parameters

network_response : JSONType

Returns

None

classmethod load_network_response(network_response: Dict[str, Any] | List[Any]) Any

parse network response. Change JSONType data to dict type data

Parameters

network_response : JSONType or Http

Returns

Any

class colda.network.api.Network

Bases: BaseNetwork

Handle network http requests

Attributes

base_url token

Methods

get_instance process_url get_request post_request get_request_chaining post_request_chaining logout

property base_url: str

Get the ipv4 address of AWS server

Returns

str

the ipv4 address of AWS server

classmethod delete()
classmethod get_instance() Network

Singleton pattern. Get instance of current class.

Returns

Network

get_request(url: str, token: str, request_name: str) Dict[str, Any] | List[Any]

Initiate a http get network request. Get the data returned by the http get network request.

Parameters

url : str token : str request_name : str

request_name is used for debugging

Returns

JSONType

get_request_chaining(url_prefix: str, url_root: str, url_suffix: str | None = None, status_code: int = 200) dict[str, Union[list[str], str]]
Handle the http get request flow:
  1. generate url

  2. http get request

  3. parse http get response

Parameters

data : JSONType url_prefix : str url_root : str url_suffix : str status_code : int

Returns

dict

post_request(url: str, token: str, request_name: str, data: dict[str, Union[list[str], str]]) Dict[str, Any] | List[Any]

Initiate a http post network request. Get the data returned by the http post network request.

Parameters

url : str token : str request_name : str

request_name is used for debugging

datadict[str, Union[list[str], str]]

data that needs to be sent to the backend

Returns

JSONType

post_request_chaining(data: dict[str, Union[list[str], str]], url_prefix: str, url_root: str, url_suffix: str | None = None, status_code: int = 200) dict[str, Union[list[str], str]]
Handle the http post request flow:
  1. generate url

  2. http post request

  3. parse http post response

Parameters

data : JSONType url_prefix : str url_root : str url_suffix : str status_code : int

Returns

dict

process_url(url_prefix: str, url_root: str, url_suffix: str | None = None) str

Add prefix and suffix to url_root

Parameters

url_prefix : str url_root : str url_suffix : str

Returns

str

test_network(url_prefix: str, url_root: str, url_suffix: str | None = None, status_code: int = 200) str
property token: str

Get the token

Returns

str

token

colda.network.base module

class colda.network.base.BaseNetwork

Bases: object

Base class for Network

final placeholder()

colda.network.dp module

class colda.network.dp.DP

Bases: object

Data processing Parse http response

Methods

load_network_response

classmethod check_network_response(network_response: Dict[str, Any] | List[Any], status_code: int = 200) None

Check status_code of network response

Parameters

network_response : JSONType

Returns

None

classmethod load_network_response(network_response: Dict[str, Any] | List[Any]) Any

parse network response. Change JSONType data to dict type data

Parameters

network_response : JSONType or Http

Returns

Any

colda.network.network module

class colda.network.network.Network

Bases: BaseNetwork

Handle network http requests

Attributes

base_url token

Methods

get_instance process_url get_request post_request get_request_chaining post_request_chaining logout

property base_url: str

Get the ipv4 address of AWS server

Returns

str

the ipv4 address of AWS server

classmethod delete()
classmethod get_instance() Network

Singleton pattern. Get instance of current class.

Returns

Network

get_request(url: str, token: str, request_name: str) Dict[str, Any] | List[Any]

Initiate a http get network request. Get the data returned by the http get network request.

Parameters

url : str token : str request_name : str

request_name is used for debugging

Returns

JSONType

get_request_chaining(url_prefix: str, url_root: str, url_suffix: str | None = None, status_code: int = 200) dict[str, Union[list[str], str]]
Handle the http get request flow:
  1. generate url

  2. http get request

  3. parse http get response

Parameters

data : JSONType url_prefix : str url_root : str url_suffix : str status_code : int

Returns

dict

post_request(url: str, token: str, request_name: str, data: dict[str, Union[list[str], str]]) Dict[str, Any] | List[Any]

Initiate a http post network request. Get the data returned by the http post network request.

Parameters

url : str token : str request_name : str

request_name is used for debugging

datadict[str, Union[list[str], str]]

data that needs to be sent to the backend

Returns

JSONType

post_request_chaining(data: dict[str, Union[list[str], str]], url_prefix: str, url_root: str, url_suffix: str | None = None, status_code: int = 200) dict[str, Union[list[str], str]]
Handle the http post request flow:
  1. generate url

  2. http post request

  3. parse http post response

Parameters

data : JSONType url_prefix : str url_root : str url_suffix : str status_code : int

Returns

dict

process_url(url_prefix: str, url_root: str, url_suffix: str | None = None) str

Add prefix and suffix to url_root

Parameters

url_prefix : str url_root : str url_suffix : str

Returns

str

test_network(url_prefix: str, url_root: str, url_suffix: str | None = None, status_code: int = 200) str
property token: str

Get the token

Returns

str

token

colda.network.utils module

Module contents