Sha256: 99f32567ca4535515d259bed14d7b034f51fefb7adff7fe9a1806b7f6249ed64

Contents?: true

Size: 1.75 KB

Versions: 4

Compression:

Stored size: 1.75 KB

Contents

# Copyright 2017 Baidu, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the
# License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
# either express or implied. See the License for the specific language governing permissions
# and limitations under the License.

# This module provide base class for BCE service clients.

require_relative 'auth/bce_v1_signer'
require_relative 'auth/bce_credentials'
require_relative 'http/base_http_client'
require_relative 'bce_client_configuration'

module Baidubce

    class BceBaseClient

        include Http
        include Auth

        def initialize(config, service_id="", region_supported=true)
            @config = config
            @service_id = service_id
            @region_supported = region_supported
            @config.endpoint = compute_endpoint if @config.endpoint.to_s.empty?
            @http_client = BaseHttpClient.new()
            @signer = BceV1Signer.new()
        end

        def compute_endpoint
            if @region_supported
                return sprintf('%s://%s.%s.%s',
                               @config.protocol,
                               @service_id,
                               @config.region,
                               DEFAULT_SERVICE_DOMAIN)
            else
                return sprintf('%s://%s.%s',
                               @config.protocol,
                               @service_id,
                               DEFAULT_SERVICE_DOMAIN)
            end

        end
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
baidubce-sdk-0.9.4 lib/baidubce/bce_base_client.rb
baidubce-sdk-0.9.3 lib/baidubce/bce_base_client.rb
baidubce-sdk-0.9.1 lib/baidubce/bce_base_client.rb
baidubce-sdk-0.9.0 lib/baidubce/bce_base_client.rb