Class: Pindo::Command::Utils::Tgate

Inherits:
Pindo::Command::Utils show all
Defined in:
lib/pindo/command/utils/tgate.rb

Constant Summary

Constants inherited from Pindo::Command

DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS

Instance Attribute Summary

Attributes inherited from Pindo::Command

#args_help_flag

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pindo::Command

run

Methods included from Funlog::Mixin

#pindo_log_instance

Methods included from Pindoconfig::Mixin

#pindo_single_config

Methods included from Githelper

#add_branch, #add_tag, #add_tag_with_check, #clone_clang_repo, #clone_devclang_repo, #clone_pindo_common_config_repo, #clone_pindo_env_config_repo, #clong_buildconfig_repo, #get_repo_base_name, #getcode_to_dir, #git_addpush_repo, #git_latest_commit_id, #local_branch_exists?, #local_tag_exists?, #prepare_gitenv, #process_need_add_files, #remote_branch_exists?, #remote_tag_exists?, #remove_branch, #remove_tag

Methods included from Executable

capture_command, #executable, execute_command, which, which!

Constructor Details

#initialize(argv) ⇒ Tgate

Returns a new instance of Tgate.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/pindo/command/utils/tgate.rb', line 41

def initialize(argv)

    @args_env_options = argv.option('env')
    @args_type_options = argv.option('type')
    @args_status_options = argv.option('status')
    @args_deviceid_options = argv.option('deviceid')
    @args_idfa_options = argv.option('idfa')
    @args_sbsid_options = argv.option('sbsid')
    @args_sutid_options = argv.option('sutid')
    @args_tzlid_options = argv.option('tzlid')
    

    super(argv)
    @additional_args = argv.remainder!
end

Class Method Details

.optionsObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pindo/command/utils/tgate.rb', line 27

def self.options
  [
    ['--env', '指定的dev或者prod环境:  --env=dev / prod'],
    ['--type', '指定的type类型:  --type=ip / device'],
    ['--status', '指定需要修改状态:  --status=normal / black / super_white '],
    ['--deviceid', '指定手机设备deviceid: --deviceid=newvalue'],
    ['--idfa', '指定手机设备idfa: --idfa=newvalue'],
    ['--sbsid', '指定手机设备sbsid: --sbsid=newvalue'],
    ['--sutid', '指定手机设备sutid: --sutid=newvalue'],
    ['--tzlid', '指定手机设备tzlid: --tzlid=newvalue'],
  ].concat(super)
end

Instance Method Details

#runObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/pindo/command/utils/tgate.rb', line 62

def run
    
    @tgate_client = TgateClient.new(base_usrl:pindo_single_config.tgate_base_url, req_config:pindo_single_config.tgate_req_config)


    current_device_info = Pindo::DeviceInfo.new

    if !@args_deviceid_options.nil?
        current_device_info.device_id = @args_deviceid_options
    end

    if !@args_idfa_options.nil?
        current_device_info.device_id = @args_idfa_options
    end

    if !@args_sbsid_options.nil?
        current_device_info.device_id = @args_sbsid_options
    end
    if !@args_sutid_options.nil?
        current_device_info.device_id = @args_sutid_options
    end
    if !@args_tzlid_options.nil?
        current_device_info.device_id = @args_tzlid_options
    end


    puts
    puts
    puts "========================================================================================================="
    puts "========================================================================================================="
    puts 


    
    puts "111"
    if !@args_status_options.nil?

        puts @args_status_options
        puts "112"
        env = "dev"
        if !@args_env_options.nil?
            env = @args_env_options
        end

        type = "ip"
        if !@args_type_options.nil? && @args_type_options.eql?("device")
            type = @args_type_options
        end

        to_status = "normal"
        if !@args_status_options.nil?
            to_status = @args_status_options
        end



        puts "当前设备信息:"
        puts JSON.pretty_generate(JSON.parse(current_device_info.to_json))
        puts 

        @tgate_client.post_update_gate_status(env_mode:env, type:type, to_status:to_status, device_info:current_device_info)    

  
    else

        puts "当前设备信息:"
        puts JSON.pretty_generate(JSON.parse(current_device_info.to_json))
        puts 
    end



    # current_device_info = Pindo::DeviceInfo.new
    # Tgate.post_update_gate_status(env_mode:"dev", type:"ip", to_status:"normal", device_info:current_device_info)    
    # Tgate.post_update_gate_status(env_mode:"dev", type:"device", to_status:"normal", device_info:current_device_info)    
    # Tgate.post_update_gate_status(env_mode:"prod", type:"ip", to_status:"normal", device_info:current_device_info)    
    # Tgate.post_update_gate_status(env_mode:"prod", type:"device", to_status:"normal", device_info:current_device_info)    


    response_data = @tgate_client.get_gate_status(device_info:current_device_info)
    puts JSON.pretty_generate(response_data)
    puts
    puts "========================================================================================================="
    puts "========================================================================================================="
    puts 

end

#validate!Object



57
58
59
60
# File 'lib/pindo/command/utils/tgate.rb', line 57

def validate!

    super
end