class Fog::DNS::HuaweiCloud::V1::Mock
Public Class Methods
data()
click to toggle source
# File lib/fog/dns/huaweicloud/v1.rb, line 27 def self.data @data ||= Hash.new do |hash, key| hash[key] = { :domains => [{ "id" => "a86dba58-0043-4cc6-a1bb-69d5e86f3ca3", "name" => "example.org.", "email" => "joe@example.org", "ttl" => 7200, "serial" => 1_404_757_531, "description" => "This is an example zone.", "created_at" => "2014-07-07T18:25:31.275934", "updated_at" => '' }], :quota => { "api_export_size" => 1000, "recordset_records" => 20, "domain_records" => 500, "domain_recordsets" => 500, "domains" => 100 } } end end
new(options = {})
click to toggle source
# File lib/fog/dns/huaweicloud/v1.rb, line 55 def initialize(options = {}) @huaweicloud_username = options[:huaweicloud_username] @huaweicloud_tenant = options[:huaweicloud_tenant] @huaweicloud_auth_uri = URI.parse(options[:huaweicloud_auth_url]) @auth_token = Fog::Mock.random_base64(64) @auth_token_expiration = (Time.now.utc + 86400).iso8601 management_url = URI.parse(options[:huaweicloud_auth_url]) management_url.port = 9001 management_url.path = '/v1' @huaweicloud_management_url = management_url.to_s @data ||= {:users => {}} unless @data[:users].detect { |u| u['name'] == options[:huaweicloud_username] } id = Fog::Mock.random_numbers(6).to_s @data[:users][id] = { 'id' => id, 'name' => options[:huaweicloud_username], 'email' => "#{options[:huaweicloud_username]}@mock.com", 'tenantId' => Fog::Mock.random_numbers(6).to_s, 'enabled' => true } end end
reset()
click to toggle source
# File lib/fog/dns/huaweicloud/v1.rb, line 51 def self.reset @data = nil end
Public Instance Methods
credentials()
click to toggle source
# File lib/fog/dns/huaweicloud/v1.rb, line 89 def credentials {:provider => 'openstack', :huaweicloud_auth_url => @huaweicloud_auth_uri.to_s, :huaweicloud_auth_token => @auth_token, :huaweicloud_region => @huaweicloud_region, :huaweicloud_management_url => @huaweicloud_management_url} end
data()
click to toggle source
# File lib/fog/dns/huaweicloud/v1.rb, line 81 def data self.class.data[@huaweicloud_username] end
get_quota(_project_id)
click to toggle source
# File lib/fog/dns/huaweicloud/v1/requests/get_quota.rb, line 16 def get_quota(_project_id) response = Excon::Response.new response.status = 200 response.body = data[:quota_updated] || data[:quota] response end
list_domains(_options = {})
click to toggle source
# File lib/fog/dns/huaweicloud/v1/requests/list_domains.rb, line 17 def list_domains(_options = {}) response = Excon::Response.new response.status = 200 response.body = {'domains' => data[:domains]} response end
reset_data()
click to toggle source
# File lib/fog/dns/huaweicloud/v1.rb, line 85 def reset_data self.class.data.delete(@huaweicloud_username) end
update_quota(_project_id, options = {})
click to toggle source
# File lib/fog/dns/huaweicloud/v1/requests/update_quota.rb, line 17 def update_quota(_project_id, options = {}) # stringify keys options = Hash[options.map { |k, v| [k.to_s, v] }] data[:quota_updated] = data[:quota].merge(options) response = Excon::Response.new response.status = 200 response.body = data[:quota_updated] response end