huawei_cloud_store_gateway_sdk 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c56a3cbf2b99dde96b529fad5f8b985ec0fd88c942ffa58091e63bf0cf1b486
4
- data.tar.gz: 15887ad04178a06917b549c1858ea37dcda663481812ca72ec11f0fa1a0eea33
3
+ metadata.gz: 1584e792fa12eee9f63d8d04ee815ae6e714f878424180470765d00f77665b1c
4
+ data.tar.gz: 975d82e953d2ecc6563031256918d32e762b02c84f6f0070a77137fe4af145c1
5
5
  SHA512:
6
- metadata.gz: 8d30bcdb27f4ec6c0c2241fa2c5ca913e64b24409eab22f32b137cd4994af94067a6be9c717df1cc3682c17c5a315befa59552479db88ad2b4893faa2d1ded70
7
- data.tar.gz: 49ba74de988b20eb81d122691659a473089f0c6314d9d64883b951c1469a3a033c3f4dd264fb57ec71df6195124346d34bf19e7421fa2a091abeb6e3b444351d
6
+ metadata.gz: 25e1f5fe8b16f714cab177f1fb4f4d84bc6eb4ded9ba00ba835b69bc98615096a2ed3203496726d61871beb19afd18fb8948c46ede9f82a06a49fae373533c9d
7
+ data.tar.gz: deca024cabacfb3895ddb8722335a30bf414a31a9ab7d911bb51f22989544da861527de46bf048ed2338bd979fe97e71f9d8e3afc0bef094e63a032b327ea3f3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- huawei_cloud_store_gateway_sdk (0.1.0)
4
+ huawei_cloud_store_gateway_sdk (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,39 +1,56 @@
1
1
  # HuaweiCloudStoreGatewaySdk
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/huawei_cloud_store_gateway_sdk`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ A Ruby SDK for interacting with Huawei Cloud's Store Gateway API. This SDK helps in generating request signatures and provides methods for configuring the SDK with your API key and secret to authenticate API requests.
6
4
 
7
5
  ## Installation
8
6
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
7
+ Add the following to your Gemfile:
8
+
9
+ ```ruby
10
+ gem 'huawei_cloud_store_gateway_sdk'
11
+
12
+ Then run bundle install:
10
13
 
11
- Install the gem and add to the application's Gemfile by executing:
14
+ bundle install
12
15
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
16
+ Alternatively, you can install it directly via the terminal:
14
17
 
15
- If bundler is not being used to manage dependencies, install the gem by executing:
18
+ gem install huawei_cloud_store_gateway_sdk
16
19
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
20
+ Configuration
18
21
 
19
- ## Usage
22
+ Before making requests with the SDK, you need to configure it with your app_key and app_secret. You can do this as follows:
20
23
 
21
- TODO: Write usage instructions here
24
+ HuaweiCloudStoreGatewaySdk.configure do |config|
25
+ config.app_key = 'your_app_key'
26
+ config.app_secret = 'your_app_secret'
27
+ end
22
28
 
23
- ## Development
29
+ Once the SDK is configured, you can access the configuration like this:
24
30
 
25
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
+ configuration = HuaweiCloudStoreGatewaySdk.configuration
32
+ puts configuration.app_key # => 'your_app_key'
33
+ puts configuration.app_secret # => 'your_app_secret'
26
34
 
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
35
+ Usage
28
36
 
29
- ## Contributing
37
+ Signing Requests
30
38
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/huawei_cloud_store_gateway_sdk. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/huawei_cloud_store_gateway_sdk/blob/master/CODE_OF_CONDUCT.md).
39
+ The sign_request method signs the request with the provided HTTP method, URL, headers, app_key, and app_secret. It generates the required signature and includes it in the Authorization header.
32
40
 
33
- ## License
41
+ Example usage:
34
42
 
35
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
43
+ url = "https://mkt.myhuaweicloud.com/api/mkp-openapi-public/global/v1/license/activate"
44
+ headers = {
45
+ "x-stage" => "RELEASE",
46
+ "X-Sdk-Date" => "20240317T144237Z",
47
+ "Content-Type" => "application/json"
48
+ }
49
+ app_key = 'your_app_key'
50
+ app_secret = 'your_app_secret'
36
51
 
37
- ## Code of Conduct
52
+ result = HuaweiCloudStoreGatewaySdk.sign_request("POST", url, headers, "")
53
+ puts result[:headers]["Authorization"]
38
54
 
39
- Everyone interacting in the HuaweiCloudStoreGatewaySdk project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/huawei_cloud_store_gateway_sdk/blob/master/CODE_OF_CONDUCT.md).
55
+ This will output the Authorization header with the correct signature.
56
+
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HuaweiCloudStoreGatewaySdk
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -27,14 +27,14 @@ module HuaweiCloudStoreGatewaySdk
27
27
  class HwStoreSDK
28
28
  attr_accessor :method, :uri, :headers, :body, :query, :app_key, :app_secret
29
29
 
30
- def initialize(method, uri, headers, app_key, app_secret, body)
30
+ def initialize(method, uri, headers, body)
31
31
  @method = method
32
32
  @uri = URI(uri)
33
33
  @headers = headers.transform_keys(&:to_s)
34
34
  @body = body
35
35
  @query = @uri.query ? URI.decode_www_form(@uri.query).to_h : {}
36
- @app_key = app_key
37
- @app_secret = app_secret
36
+ @app_key = HuaweiCloudStoreGatewaySdk.configuration.app_key
37
+ @app_secret = HuaweiCloudStoreGatewaySdk.configuration.app_secret
38
38
  end
39
39
 
40
40
  def full_path
@@ -44,8 +44,8 @@ module HuaweiCloudStoreGatewaySdk
44
44
  end
45
45
  end
46
46
 
47
- def sign_request(method, uri, headers, app_key, app_secret, body)
48
- request = HwStoreSDK.new(method, uri, headers, app_key, app_secret, body)
47
+ def sign_request(method, uri, headers, body)
48
+ request = HwStoreSDK.new(method, uri, headers, body)
49
49
  sign_headers(request)
50
50
  {
51
51
  url: request.full_path,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: huawei_cloud_store_gateway_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jackie