• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (Python SDK)
  4. Initialization
  5. ObsClient Initialization

ObsClient Initialization

API Description

ObsClient functions as the Python client for accessing OBS. It offers callers a series of APIs for interaction with OBS. These APIs are used for managing and operating resources, such as buckets and objects, stored in OBS.

Namespace

Class

Module

ObsClient

com.obs.client.obs_client

Method Definition

ObsClient.__init__(access_key_id, secret_access_key, is_secure, server, ssl_verify, port, max_retry_count, timeout, chunk_size, long_conn_mode, proxy_host, proxy_port, proxy_username, proxy_password)

Parameter Description

Field

Type

Optional or Mandatory

Description

access_key_id

str

Mandatory

Access key ID (AK)

secret_access_key

str

Mandatory

Secret access key (SK)

is_secure

bool

Optional

Whether to access OBS over HTTPS. The default value is True.

server

str

Mandatory

Endpoint for accessing OBS.

ssl_verify

str

or

bool

Optional

Whether to verify server-side certificates. Possible values are:

  • Path to the server-side root certificate file in .pem format
  • True: The certificate list will be obtained from the root certificate library and the certificates of the operating system (Windows only) will be verified.
  • False: The server-side certificates will not be verified.

The default value is False.

port

int

Optional

Port number. The default value is 80 when HTTP is used or 443 when HTTPS is used.

max_retry_count

int

Optional

Maximum number of retries when an HTTP/HTTPS connection is abnormal. The default value is 3.

timeout

int

Optional

Timeout period (in seconds) of an HTTP/HTTPS request. The default value is 60.

chunk_size

int

Optional

Chunk size (in bytes) set for reading and writing socket streams. The default value is 65536.

long_conn_mode

bool

Optional

Whether to enable the long connection mode. The default value is False.

proxy_host

str

Optional

Host IP address of the proxy server. The default value is None.

proxy_port

int

Optional

Port number of the proxy server. The default value is None.

proxy_username

str

Optional

User name used for connecting to the proxy server. The default value is None.

proxy_password

str

Optional

Password used for connecting to the proxy server. The default value is None.

Sample Code

# Import the module.
from com.obs.client.obs_client import ObsClient

# Create an instance of ObsClient.
obsClient = ObsClient(
    access_key_id='*** Provide your Access Key ***',    
    secret_access_key='*** Provide your Secret Key ***',    
    is_secure=True,
    server='yourdomainname',
    ssl_verify=False,
    port=443,
    max_retry_count=1,
    timeout=20,
    chunk_size=65536,
    long_conn_mode=False
)