Module: Gzr::Project
- Included in:
- Commands::Project::Branch, Commands::Project::Cat, Commands::Project::Checkout, Commands::Project::Deploy, Commands::Project::DeployKey, Commands::Project::Import, Commands::Project::Ls, Commands::Project::Update
- Defined in:
- lib/gzr/modules/project.rb
Instance Method Summary collapse
- #all_git_branches(proj_id) ⇒ Object
- #all_projects(fields: 'id') ⇒ Object
- #cat_project(project_id) ⇒ Object
- #create_git_deploy_key(id) ⇒ Object
- #create_project(body) ⇒ Object
- #deploy_to_production(proj_id) ⇒ Object
- #git_branch(proj_id) ⇒ Object
- #git_deploy_key(id) ⇒ Object
- #trim_project(data) ⇒ Object
- #update_git_branch(proj_id, name) ⇒ Object
- #update_project(id, body) ⇒ Object
Instance Method Details
#all_git_branches(proj_id) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/gzr/modules/project.rb', line 107 def all_git_branches(proj_id) begin @sdk.all_git_branches(proj_id).collect { |b| b.to_attrs } rescue LookerSDK::NotFound => e [] rescue LookerSDK::Error => e say_error "Error running all_git_branches(#{proj_id})" say_error e raise end end |
#all_projects(fields: 'id') ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gzr/modules/project.rb', line 27 def all_projects(fields: 'id') begin @sdk.all_projects({ fields: fields }).collect { |p| p.to_attrs } rescue LookerSDK::NotFound => e return [] rescue LookerSDK::Error => e say_error "Error querying all_projects(#{fields})" say_error e raise end end |
#cat_project(project_id) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/gzr/modules/project.rb', line 39 def cat_project(project_id) begin @sdk.project(project_id)&.to_attrs rescue LookerSDK::NotFound => e say_error "project(#{project_id}) not found" say_error e raise rescue LookerSDK::Error => e say_error "Error getting project(#{project_id})" say_error e raise end end |
#create_git_deploy_key(id) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/gzr/modules/project.rb', line 95 def create_git_deploy_key(id) begin @sdk.create_git_deploy_key(id) rescue LookerSDK::NotFound => e nil rescue LookerSDK::Error => e say_error "Error running create_git_deploy_key(#{id})" say_error e raise end end |
#create_project(body) ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/gzr/modules/project.rb', line 59 def create_project(body) begin @sdk.create_project(body)&.to_attrs rescue LookerSDK::Error => e say_error "Error running create_project(#{JSON.pretty_generate(body)})" say_error e raise end end |
#deploy_to_production(proj_id) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/gzr/modules/project.rb', line 131 def deploy_to_production(proj_id) begin @sdk.deploy_to_production(proj_id) rescue LookerSDK::NotFound => e say_error "deploy_to_production(#{proj_id}) not found" say_error e raise rescue LookerSDK::Error => e say_error "Error running deploy_to_production(#{proj_id})" say_error e raise end end |
#git_branch(proj_id) ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/gzr/modules/project.rb', line 119 def git_branch(proj_id) begin @sdk.git_branch(proj_id).to_attrs rescue LookerSDK::NotFound => e nil rescue LookerSDK::Error => e say_error "Error running git_branch(#{proj_id})" say_error e raise end end |
#git_deploy_key(id) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/gzr/modules/project.rb', line 83 def git_deploy_key(id) begin @sdk.git_deploy_key(id) rescue LookerSDK::NotFound => e nil rescue LookerSDK::Error => e say_error "Error running git_deploy_key(#{id})" say_error e raise end end |
#trim_project(data) ⇒ Object
53 54 55 56 57 |
# File 'lib/gzr/modules/project.rb', line 53 def trim_project(data) data.select do |k,v| keys_to_keep('create_project').include? k end end |
#update_git_branch(proj_id, name) ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/gzr/modules/project.rb', line 145 def update_git_branch(proj_id, name) body = { name: name } begin @sdk.update_git_branch(proj_id, body)&.to_attrs rescue LookerSDK::NotFound => e say_error "update_git_branch(#{proj_id},#{JSON.pretty_generate(body)}) not found" say_error e raise rescue LookerSDK::Error => e say_error "Error running update_git_branch(#{proj_id},#{JSON.pretty_generate(body)})" say_error e raise end end |
#update_project(id, body) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/gzr/modules/project.rb', line 69 def update_project(id,body) begin @sdk.update_project(id,body)&.to_attrs rescue LookerSDK::NotFound => e say_error "update_project(#{id},#{JSON.pretty_generate(body)} not found)" say_error e raise rescue LookerSDK::Error => e say_error "Error running update_project(#{id},#{JSON.pretty_generate(body)})" say_error e raise end end |