repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/integration/role/group_add_spec.rb
spec/integration/role/group_add_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. RSpec.describe "`gzr role group_add` command", type: :cli do it "executes `gzr role help group_add` command successfully" do output = `gzr role help group_add` expected_output = <<-OUT Usage: gzr role group_add ROLE_ID GROUP_ID GROUP_ID GROUP_ID ... Options: -h, [--help], [--no-help] # Display usage information Add indicated groups to role OUT expect(output).to eq(expected_output) end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/integration/role/group_rm_spec.rb
spec/integration/role/group_rm_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. RSpec.describe "`gzr role group_rm` command", type: :cli do it "executes `gzr role help group_rm` command successfully" do output = `gzr role help group_rm` expected_output = <<-OUT Usage: gzr role group_rm ROLE_ID GROUP_ID GROUP_ID GROUP_ID ... Options: -h, [--help], [--no-help] # Display usage information Remove indicated groups from role OUT expect(output).to eq(expected_output) end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/integration/role/user_ls_spec.rb
spec/integration/role/user_ls_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. RSpec.describe "`gzr role user_ls` command", type: :cli do it "executes `gzr role help user_ls` command successfully" do output = `gzr role help user_ls` expected_output = <<-OUT Usage: gzr role user_ls ROLE_ID Options: -h, [--help], [--no-help] # Display usage information [--fields=FIELDS] # Fields to display # Default: id,first_name,last_name,email [--plain], [--no-plain] # print without any extra formatting [--csv], [--no-csv] # output in csv format per RFC4180 [--all-users], [--no-all-users] # Show users with this role through a group membership List the users assigned to a role OUT expect(output).to eq(expected_output) end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/integration/role/ls_spec.rb
spec/integration/role/ls_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. RSpec.describe "`gzr role ls` command", type: :cli do it "executes `gzr role help ls` command successfully" do output = `gzr role help ls` expected_output = <<-OUT Usage: gzr role ls Options: -h, [--help], [--no-help] # Display usage information [--fields=FIELDS] # Fields to display # Default: id,name,permission_set(id,name,permissions),model_set(id,name,models) [--plain], [--no-plain] # print without any extra formatting [--csv], [--no-csv] # output in csv format per RFC4180 Display all roles OUT expect(output).to eq(expected_output) end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/integration/role/user_rm_spec.rb
spec/integration/role/user_rm_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. RSpec.describe "`gzr role user_rm` command", type: :cli do it "executes `gzr role help user_rm` command successfully" do output = `gzr role help user_rm` expected_output = <<-OUT Usage: gzr role user_rm ROLE_ID USER_ID USER_ID USER_ID ... Options: -h, [--help], [--no-help] # Display usage information Remove indicated users from role OUT expect(output).to eq(expected_output) end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/integration/role/group_ls_spec.rb
spec/integration/role/group_ls_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. RSpec.describe "`gzr role group_ls` command", type: :cli do it "executes `gzr role help group_ls` command successfully" do output = `gzr role help group_ls` expected_output = <<-OUT Usage: gzr role group_ls ROLE_ID Options: -h, [--help], [--no-help] # Display usage information [--fields=FIELDS] # Fields to display # Default: id,name,external_group_id [--plain], [--no-plain] # print without any extra formatting [--csv], [--no-csv] # output in csv format per RFC4180 List the groups assigned to a role OUT expect(output).to eq(expected_output) end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/integration/role/user_add_spec.rb
spec/integration/role/user_add_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. RSpec.describe "`gzr role user_add` command", type: :cli do it "executes `gzr role help user_add` command successfully" do output = `gzr role help user_add` expected_output = <<-OUT Usage: gzr role user_add ROLE_ID USER_ID USER_ID USER_ID ... Options: -h, [--help], [--no-help] # Display usage information Add indicated users to role OUT expect(output).to eq(expected_output) end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/integration/role/rm_spec.rb
spec/integration/role/rm_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. RSpec.describe "`gzr role rm` command", type: :cli do it "executes `gzr role help rm` command successfully" do output = `gzr role help rm` expected_output = <<-OUT Usage: gzr role rm ROLE_ID Options: -h, [--help], [--no-help] # Display usage information Delete a role OUT expect(output).to eq(expected_output) end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/integration/role/cat_spec.rb
spec/integration/role/cat_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. RSpec.describe "`gzr role cat` command", type: :cli do it "executes `gzr role help cat` command successfully" do output = `gzr role help cat` expected_output = <<-OUT Usage: gzr role cat ROLE_ID Options: -h, [--help], [--no-help] # Display usage information [--dir=DIR] # Directory to get output file [--trim], [--no-trim] # Trim output to minimal set of fields for later import Output the JSON representation of a role to screen/file OUT expect(output).to eq(expected_output) end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/integration/attribute/set_group_value_spec.rb
spec/integration/attribute/set_group_value_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. RSpec.describe "`gzr attribute set_group_value` command", type: :cli do it "executes `gzr attribute help set_group_value` command successfully" do output = `gzr attribute help set_group_value` expected_output = <<-OUT Usage: gzr attribute set_group_value GROUP_ID|GROUP_NAME ATTR_ID|ATTR_NAME VALUE Options: -h, [--help], [--no-help] # Display usage information Set a user attribute value for a group OUT expect(output).to eq(expected_output) end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/integration/attribute/import_spec.rb
spec/integration/attribute/import_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. RSpec.describe "`gzr attribute import` command", type: :cli do it "executes `gzr attribute help import` command successfully" do output = `gzr attribute help import` expected_output = <<-OUT Usage: gzr attribute import FILE Options: -h, [--help], [--no-help] # Display usage information [--plain], [--no-plain] # Provide minimal response information [--force] # If the user attribute already exists, modify it Import a user attribute from a file OUT expect(output).to eq(expected_output) end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/integration/attribute/ls_spec.rb
spec/integration/attribute/ls_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. RSpec.describe "`gzr attribute ls` command", type: :cli do it "executes `gzr attribute help ls` command successfully" do output = `gzr attribute help ls` expected_output = <<-OUT Usage: gzr attribute ls Options: -h, [--help], [--no-help] # Display usage information [--fields=FIELDS] # Fields to display # Default: id,name,label,type,default_value [--plain], [--no-plain] # print without any extra formatting [--csv], [--no-csv] # output in csv format per RFC4180 List all the defined user attributes OUT expect(output).to eq(expected_output) end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/integration/attribute/create_spec.rb
spec/integration/attribute/create_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. RSpec.describe "`gzr attribute create` command", type: :cli do it "executes `gzr attribute help create` command successfully" do output = `gzr attribute help create` expected_output = <<-OUT Usage: gzr attribute create ATTR_NAME [ATTR_LABEL] [OPTIONS] Options: -h, [--help], [--no-help] # Display usage information [--plain], [--no-plain] # Provide minimal response information [--force] # If the user attribute already exists, modify it [--type=TYPE] # "string", "number", "datetime", "yesno", "zipcode" # Default: string [--default-value=DEFAULT-VALUE] # default value to be used if one not otherwise set [--is-hidden], [--no-is-hidden] # can a non-admin user view the value [--can-view], [--no-can-view] # can a non-admin user view the value # Default: true [--can-edit], [--no-can-edit] # can a user change the value themself # Default: true [--domain-allowlist=DOMAIN-ALLOWLIST] # what domains can receive the value of a hidden attribute. Create or modify an attribute OUT expect(output).to eq(expected_output) end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/integration/attribute/get_group_value_spec.rb
spec/integration/attribute/get_group_value_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. RSpec.describe "`gzr attribute get_group_value` command", type: :cli do it "executes `gzr attribute help get_group_value` command successfully" do output = `gzr attribute help get_group_value` expected_output = <<-OUT Usage: gzr attribute get_group_value GROUP_ID|GROUP_NAME ATTR_ID|ATTR_NAME Options: -h, [--help], [--no-help] # Display usage information Retrieve a user attribute value for a group OUT expect(output).to eq(expected_output) end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/integration/attribute/rm_spec.rb
spec/integration/attribute/rm_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. RSpec.describe "`gzr attribute rm` command", type: :cli do it "executes `gzr attribute help rm` command successfully" do output = `gzr attribute help rm` expected_output = <<-OUT Usage: gzr attribute rm ATTR_ID|ATTR_NAME Options: -h, [--help], [--no-help] # Display usage information [--plain], [--no-plain] # Provide minimal response information Delete a user attribute OUT expect(output).to eq(expected_output) end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/integration/attribute/cat_spec.rb
spec/integration/attribute/cat_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. RSpec.describe "`gzr attribute cat` command", type: :cli do it "executes `gzr attribute help cat` command successfully" do output = `gzr attribute help cat` expected_output = <<-OUT Usage: gzr attribute cat ATTR_ID|ATTR_NAME Options: -h, [--help], [--no-help] # Display usage information [--fields=FIELDS] # Fields to display [--dir=DIR] # Directory to store output file Output json information about an attribute to screen or file OUT expect(output).to eq(expected_output) end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/integration/permission/ls_spec.rb
spec/integration/permission/ls_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. RSpec.describe "`gzr permission ls` command", type: :cli do it "executes `gzr permission help ls` command successfully" do output = `gzr permission help ls` expected_output = <<-OUT Usage: gzr permission ls Options: -h, [--help], [--no-help] # Display usage information [--plain], [--no-plain] # print without any extra formatting [--csv], [--no-csv] # output in csv format per RFC4180 List all available permissions OUT expect(output).to eq(expected_output) end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/live/user/me_spec.rb
spec/live/user/me_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. RSpec.describe "`gzr user me` command", type: :cli do it "executes `user me` command successfully against a live server" do output = `gzr user me --fields id,email,last_name,first_name --width=130` expect(output).to eq <<-OUT +--+------------------------+---------+----------+ |id|email |last_name|first_name| +--+------------------------+---------+----------+ | 1|firstadmin@schmoogle.com|Rekool |Firstadmin| +--+------------------------+---------+----------+ OUT end end if ENV["LOOKERSDK_BASE_URL"]
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/query/runquery_spec.rb
spec/unit/query/runquery_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/query/runquery' RSpec.describe Gzr::Commands::Query::RunQuery do it "executes `query runquery` command successfully" do require 'sawyer' data = <<-OUT Orders Created Month Orders Count Customers Count 2018-09 31 31 2018-08 75 68 2018-07 83 73 2018-06 89 78 2018-05 78 63 2018-04 79 74 OUT mock_sdk = Object.new allow(mock_sdk).to receive(:logout) allow(mock_sdk).to receive(:query) do |body| end allow(mock_sdk).to receive(:run_query) do |query_id,body,&block| block.call(data, data.length) end output = StringIO.new options = {} command = Gzr::Commands::Query::RunQuery.new("1",{:format => 'txt'}) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq(data) end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/user/delete_spec.rb
spec/unit/user/delete_spec.rb
# The MIT License (MIT) # Copyright (c) 2023 Mike DeAngelo Google, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/user/delete' RSpec.describe Gzr::Commands::User::Delete do it "executes `user delete` command successfully" do mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:delete_user) do |user_id| return "" end output = StringIO.new options = {} command = Gzr::Commands::User::Delete.new(1,options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq("") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/user/ls_spec.rb
spec/unit/user/ls_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/user/ls' RSpec.describe Gzr::Commands::User::Ls do it "executes `ls` command successfully" do require 'sawyer' mock_response = double(Sawyer::Resource, { :id=>1, :last_name=>"foo", :first_name=>"bar", :email=>"fbar@my.company.com" }) allow(mock_response).to receive(:to_attrs).and_return({ :id=>1, :last_name=>"foo", :first_name=>"bar", :email=>"fbar@my.company.com" }) mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:all_users) do |body| return body[:offset].nil? ? [mock_response] : [] end output = StringIO.new options = { :fields=>'id,last_name,first_name,email' } command = Gzr::Commands::User::Ls.new(options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT +--+---------+----------+-------------------+ |id|last_name|first_name|email | +--+---------+----------+-------------------+ | 1|foo |bar |fbar@my.company.com| +--+---------+----------+-------------------+ OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/user/enable_spec.rb
spec/unit/user/enable_spec.rb
# The MIT License (MIT) # Copyright (c) 2023 Mike DeAngelo Google, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/user/enable' RSpec.describe Gzr::Commands::User::Enable do it "executes `user enable` command successfully" do mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:update_user) do |user_id,body| o = Object.new o.define_singleton_method(:to_attrs) do return { id: user_id, is_disabled: body[:is_disabled] } end return o end output = StringIO.new options = {} command = Gzr::Commands::User::Enable.new(1,options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq("") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/user/disable_spec.rb
spec/unit/user/disable_spec.rb
# The MIT License (MIT) # Copyright (c) 2023 Mike DeAngelo Google, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/user/disable' RSpec.describe Gzr::Commands::User::Disable do it "executes `user disable` command successfully" do mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:update_user) do |user_id,body| o = Object.new o.define_singleton_method(:to_attrs) do return { id: user_id, is_disabled: body[:is_disabled] } end return o end output = StringIO.new options = {} command = Gzr::Commands::User::Disable.new(1,options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq("") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/user/cat_spec.rb
spec/unit/user/cat_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/user/cat' RSpec.describe Gzr::Commands::User::Cat do it "executes `user cat` command successfully" do require 'sawyer' mock_response = double(Sawyer::Resource, { :id=>1, :last_name=>"foo", :first_name=>"bar", :email=>"fbar@my.company.com" }) allow(mock_response).to receive(:to_attrs).and_return({ :id=>1, :last_name=>"foo", :first_name=>"bar", :email=>"fbar@my.company.com" }) mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:user) do |user_id,body| return mock_response end output = StringIO.new options = {} command = Gzr::Commands::User::Cat.new(1,options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT { "id": 1, "last_name": "foo", "first_name": "bar", "email": "fbar@my.company.com" } OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/user/me_spec.rb
spec/unit/user/me_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/user/me' RSpec.describe Gzr::Commands::User::Me do it "executes `me` command successfully" do require 'sawyer' mock_response = double(Sawyer::Resource, { :id=>1, :last_name=>"foo", :first_name=>"bar", :email=>"fbar@my.company.com" }) allow(mock_response).to receive(:to_attrs).and_return({ :id=>1, :last_name=>"foo", :first_name=>"bar", :email=>"fbar@my.company.com" }) mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:me) do |fields| return mock_response end output = StringIO.new options = { :fields=>'id,last_name,first_name,email' } command = Gzr::Commands::User::Me.new(options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT +--+---------+----------+-------------------+ |id|last_name|first_name|email | +--+---------+----------+-------------------+ | 1|foo |bar |fbar@my.company.com| +--+---------+----------+-------------------+ OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/model/ls_spec.rb
spec/unit/model/ls_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/model/ls' RSpec.describe Gzr::Commands::Model::Ls do it "executes `ls` command successfully" do require 'sawyer' response_doc = { :name=>"foo", :label=>"bar", :project_name=>"baz" } mock_response = double(Sawyer::Resource, response_doc) allow(mock_response).to receive(:to_attrs).and_return(response_doc) mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:all_lookml_models) do |req| return [mock_response] end output = StringIO.new options = { :fields=>'name,label,project_name' } command = Gzr::Commands::Model::Ls.new(options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT +----+-----+------------+ |name|label|project_name| +----+-----+------------+ |foo |bar |baz | +----+-----+------------+ OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/plan/import_spec.rb
spec/unit/plan/import_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/plan/import' RSpec.describe Gzr::Commands::Plan::Import do it "executes `plan import` command successfully" do require 'sawyer' me_response_doc = { :id=>1000, :first_name=>"John", :last_name=>"Jones", :email=>"jjones@example.com" } mock_me_response = double(Sawyer::Resource, me_response_doc) allow(mock_me_response).to receive(:to_attrs).and_return(me_response_doc) plan_response_doc = { :id=>1 } mock_plan_response = double(Sawyer::Resource, plan_response_doc) allow(mock_plan_response).to receive(:to_attrs).and_return(plan_response_doc) mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:me) do |req| return mock_me_response end mock_sdk.define_singleton_method(:scheduled_plans_for_look) do |look_id,req| return [] end mock_sdk.define_singleton_method(:create_scheduled_plan) do |req| return mock_plan_response end mock_sdk.define_singleton_method(:operations) do { "create_scheduled_plan"=> { :info=>{ :parameters=>[ { :in=>"body", :schema=>{ :$ref=>"#/definitions/ScheduledPlan" } } ] } } } end mock_sdk.define_singleton_method(:swagger) do JSON.parse <<-SWAGGER, {:symbolize_names => true} { "definitions": { "ScheduledPlan": { "properties": { "name": { "type": "string", "description": "Name", "x-looker-nullable": true }, "user_id": { "type": "integer", "format": "int64", "description": "User Id which owns this ScheduledPlan", "x-looker-nullable": true }, "run_as_recipient": { "type": "boolean", "description": "Whether schedule is ran as recipient (only applicable for email recipients)", "x-looker-nullable": false }, "enabled": { "type": "boolean", "description": "Whether the ScheduledPlan is enabled", "x-looker-nullable": false }, "look_id": { "type": "integer", "format": "int64", "description": "Id of a look", "x-looker-nullable": true }, "dashboard_id": { "type": "integer", "format": "int64", "description": "Id of a dashboard", "x-looker-nullable": true }, "lookml_dashboard_id": { "type": "string", "description": "Id of a LookML dashboard", "x-looker-nullable": true }, "filters_string": { "type": "string", "description": "Query string to run look or dashboard with", "x-looker-nullable": true }, "require_results": { "type": "boolean", "description": "Delivery should occur if running the dashboard or look returns results", "x-looker-nullable": false }, "require_no_results": { "type": "boolean", "description": "Delivery should occur if the dashboard look does not return results", "x-looker-nullable": false }, "require_change": { "type": "boolean", "description": "Delivery should occur if data have changed since the last run", "x-looker-nullable": false }, "send_all_results": { "type": "boolean", "description": "Will run an unlimited query and send all results.", "x-looker-nullable": false }, "crontab": { "type": "string", "description": "Vixie-Style crontab specification when to run", "x-looker-nullable": true }, "datagroup": { "type": "string", "description": "Name of a datagroup; if specified will run when datagroup triggered (can't be used with cron string)", "x-looker-nullable": true }, "timezone": { "type": "string", "description": "Timezone for interpreting the specified crontab (default is Looker instance timezone)", "x-looker-nullable": true }, "query_id": { "type": "string", "description": "Query id", "x-looker-nullable": true }, "run_once": { "type": "boolean", "description": "Whether the plan in question should only be run once (usually for testing)", "x-looker-nullable": false }, "include_links": { "type": "boolean", "description": "Whether links back to Looker should be included in this ScheduledPlan", "x-looker-nullable": false } }, "x-looker-status": "beta" } } } SWAGGER end output = StringIO.new file = nil options = {} command = Gzr::Commands::Plan::Import.new(StringIO.new( <<-PLAN { "name": "foo", "run_as_recipient": null, "enabled": true, "look_id": 1000, "dashboard_id": null, "lookml_dashboard_id": null, "filters_string": null, "dashboard_filters": null, "require_results": false, "require_no_results": false, "require_change": false, "send_all_results": false, "crontab": "*/5 * * * *", "datagroup": null, "timezone": "America/Los_Angeles", "query_id": null, "scheduled_plan_destination": [ ], "run_once": false, "include_links": false } PLAN ), "LOOK", 1, options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq("Imported plan 1\n") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/plan/ls_spec.rb
spec/unit/plan/ls_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/plan/ls' RSpec.describe Gzr::Commands::Plan::Ls do it "executes `plan ls` command successfully" do require 'sawyer' user_doc = { :id=>1000, :display_name=>"John Smith" } response_doc = { :id=>1, :name=>"foo", :title=>"foo", :user=>user_doc, :look_id=>100, :dashboard_id=>nil, :lookml_dashboard_id=>nil } mock_response = double(Sawyer::Resource, response_doc) allow(mock_response).to receive(:to_attrs).and_return(response_doc) mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:all_scheduled_plans) do |body| return [mock_response,mock_response] end output = StringIO.new options = {:fields=>'id,name,title,user(id,display_name),look_id,dashboard_id,lookml_dashboard_id'} options[:width] = 130 command = Gzr::Commands::Plan::Ls.new(options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT +--+----+-----+-------+-----------------+-------+------------+-------------------+ |id|name|title|user.id|user.display_name|look_id|dashboard_id|lookml_dashboard_id| +--+----+-----+-------+-----------------+-------+------------+-------------------+ | 1|foo |foo | 1000|John Smith | 100| | | | 1|foo |foo | 1000|John Smith | 100| | | +--+----+-----+-------+-----------------+-------+------------+-------------------+ OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/plan/failures_spec.rb
spec/unit/plan/failures_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/plan/failures' RSpec.describe Gzr::Commands::Plan::Failures do it "executes `plan failures` command successfully" do require 'sawyer' response_doc = { :"scheduled_plan.id"=>23, :"user.name"=>"Jake Johnson", :"scheduled_job.status"=>"failure", :"scheduled_job.id"=>13694, :"scheduled_job.created_time"=>"2018-06-19 11:00:32", :"scheduled_plan.next_run_time"=>"2018-06-20 11:00:00" } mock_response = double(Sawyer::Resource, response_doc) allow(mock_response).to receive(:to_attrs).and_return(response_doc) mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:run_inline_query) do |format,query| return [mock_response] end output = StringIO.new options = {:width=>1024} command = Gzr::Commands::Plan::Failures.new(options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT +-----------------+-------------------+-------+------------+--------------------+----------------+--------------------------+----------------------------+----------------------+---------------------------+----------------------------------+ |scheduled_plan.id|scheduled_plan.name|user.id|user.name |scheduled_job.status|scheduled_job.id|scheduled_job.created_time|scheduled_plan.next_run_time|scheduled_plan.look_id|scheduled_plan.dashboard_id|scheduled_plan.lookml_dashboard_id| +-----------------+-------------------+-------+------------+--------------------+----------------+--------------------------+----------------------------+----------------------+---------------------------+----------------------------------+ | 23| | |Jake Johnson|failure | 13694|2018-06-19 11:00:32 |2018-06-20 11:00:00 | | | | +-----------------+-------------------+-------+------------+--------------------+----------------+--------------------------+----------------------------+----------------------+---------------------------+----------------------------------+ OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/plan/run_spec.rb
spec/unit/plan/run_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/plan/run' RSpec.describe Gzr::Commands::Plan::RunIt do it "executes `plan run` command successfully" do require 'sawyer' mock_response = double(Sawyer::Resource, { :id=>1, :name=>"foo" }) allow(mock_response).to receive(:to_attrs).and_return({ :id=>1, :name=>"foo" }) mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:scheduled_plan) do |plan_id, body| return mock_response end mock_sdk.define_singleton_method(:scheduled_plan_run_once) do |body| return end output = StringIO.new options = {} command = Gzr::Commands::Plan::RunIt.new(1,options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq("Executed plan 1\n") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/plan/enable_spec.rb
spec/unit/plan/enable_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/plan/enable' RSpec.describe Gzr::Commands::Plan::Enable do it "executes `plan enable` command successfully" do require 'sawyer' plan_response_doc = { :id=>1 } mock_plan_response = double(Sawyer::Resource, plan_response_doc) allow(mock_plan_response).to receive(:to_attrs).and_return(plan_response_doc) mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:update_scheduled_plan) do |plan_id,req| return mock_plan_response end output = StringIO.new options = {} command = Gzr::Commands::Plan::Enable.new(1,options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq("Enabled plan 1\n") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/plan/disable_spec.rb
spec/unit/plan/disable_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/plan/disable' RSpec.describe Gzr::Commands::Plan::Disable do it "executes `plan disable` command successfully" do require 'sawyer' plan_response_doc = { :id=>1 } mock_plan_response = double(Sawyer::Resource, plan_response_doc) allow(mock_plan_response).to receive(:to_attrs).and_return(plan_response_doc) mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:update_scheduled_plan) do |plan_id,req| return mock_plan_response end output = StringIO.new options = {} command = Gzr::Commands::Plan::Disable.new(1,options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq("Disabled plan 1\n") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/plan/rm_spec.rb
spec/unit/plan/rm_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/plan/rm' RSpec.describe Gzr::Commands::Plan::Rm do it "executes `plan rm` command successfully" do mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:delete_scheduled_plan) do |plan_id| return end output = StringIO.new options = {} command = Gzr::Commands::Plan::Rm.new(1,options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq("") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/plan/cat_spec.rb
spec/unit/plan/cat_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/plan/cat' RSpec.describe Gzr::Commands::Plan::Cat do it "executes `plan cat` command successfully" do require 'sawyer' mock_response = double(Sawyer::Resource, { :id=>1, :name=>"foo" }) allow(mock_response).to receive(:to_attrs).and_return({ :id=>1, :name=>"foo" }) mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:scheduled_plan) do |plan_id, body| return mock_response end output = StringIO.new options = {} command = Gzr::Commands::Plan::Cat.new(1,options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT { "id": 1, "name": "foo" } OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/connection/ls_spec.rb
spec/unit/connection/ls_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/connection/ls' RSpec.describe Gzr::Commands::Connection::Ls do it "executes `ls` command successfully" do require 'sawyer' response_doc = { :name=>"foo", :dialect=>"mysql", :host=>"db.example.com", :port=>3306, :database=>"looker", :schema=>"test" } mock_response = double(Sawyer::Resource, response_doc) allow(mock_response).to receive(:to_attrs).and_return(response_doc) mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:all_connections) do |req| return [mock_response] end output = StringIO.new options = { :fields=>'name,dialect,host,port,database,schema' } command = Gzr::Commands::Connection::Ls.new(options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT +----+-------+--------------+----+--------+------+ |name|dialect|host |port|database|schema| +----+-------+--------------+----+--------+------+ |foo |mysql |db.example.com|3306|looker |test | +----+-------+--------------+----+--------+------+ OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/connection/dialects_spec.rb
spec/unit/connection/dialects_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/connection/dialects' RSpec.describe Gzr::Commands::Connection::Dialects do it "executes `dialects` command successfully" do require 'sawyer' response_doc = { :name=>"foo", :label=>"Foo" } mock_response = double(Sawyer::Resource, response_doc) allow(mock_response).to receive(:to_attrs).and_return(response_doc) mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:all_dialect_infos) do |req| return [mock_response] end output = StringIO.new options = { :fields=>'name,label' } command = Gzr::Commands::Connection::Dialects.new(options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT +----+-----+ |name|label| +----+-----+ |foo |Foo | +----+-----+ OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/group/member_users_spec.rb
spec/unit/group/member_users_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/group/member_users' RSpec.describe Gzr::Commands::Group::MemberUsers do it "executes `member_users` command successfully" do require 'sawyer' mock_response_doc = { :id=>1, :last_name=>"foo", :first_name=>"bar", :email=>"fbar@my.company.com" } mock_response = double(Sawyer::Resource, mock_response_doc) allow(mock_response).to receive(:to_attrs).and_return(mock_response_doc) mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:all_group_users) do |group_id,body| return body[:page] == 1 ? [mock_response] : [] end output = StringIO.new options = { :fields=>'id,last_name,first_name,email' } command = Gzr::Commands::Group::MemberUsers.new(1,options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT +--+---------+----------+-------------------+ |id|last_name|first_name|email | +--+---------+----------+-------------------+ | 1|foo |bar |fbar@my.company.com| +--+---------+----------+-------------------+ OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/group/ls_spec.rb
spec/unit/group/ls_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/group/ls' RSpec.describe Gzr::Commands::Group::Ls do it "executes `ls` command successfully" do require 'sawyer' mock_response_doc = { :id=>1, :name=>"foo", :user_count=>5, :contains_current_user=>false, :externally_managed=>nil, :external_group_id=>nil } mock_response = double(Sawyer::Resource, mock_response_doc) allow(mock_response).to receive(:to_attrs).and_return(mock_response_doc) mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:all_groups) do |body| return body[:page] == 1 ? [mock_response] : [] end output = StringIO.new options = { :fields=>'id,name,user_count,contains_current_user,externally_managed,external_group_id' } command = Gzr::Commands::Group::Ls.new(options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT +--+----+----------+---------------------+------------------+-----------------+ |id|name|user_count|contains_current_user|externally_managed|external_group_id| +--+----+----------+---------------------+------------------+-----------------+ | 1|foo | 5|false | | | +--+----+----------+---------------------+------------------+-----------------+ OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/group/member_groups_spec.rb
spec/unit/group/member_groups_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/group/member_groups' RSpec.describe Gzr::Commands::Group::MemberGroups do it "executes `member_groups` command successfully" do require 'sawyer' mock_response_doc = { :id=>1, :name=>"foo", :user_count=>5, :contains_current_user=>false, :externally_managed=>nil, :external_group_id=>nil } mock_response = double(Sawyer::Resource, mock_response_doc) allow(mock_response).to receive(:to_attrs).and_return(mock_response_doc) mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:all_group_groups) do |group_id,body| return [mock_response] end output = StringIO.new options = { :fields=>'id,name,user_count,contains_current_user,externally_managed,external_group_id' } command = Gzr::Commands::Group::MemberGroups.new(1,options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT +--+----+----------+---------------------+------------------+-----------------+ |id|name|user_count|contains_current_user|externally_managed|external_group_id| +--+----+----------+---------------------+------------------+-----------------+ | 1|foo | 5|false | | | +--+----+----------+---------------------+------------------+-----------------+ OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/dashboard/import_spec.rb
spec/unit/dashboard/import_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/dashboard/import' RSpec.describe Gzr::Commands::Dashboard::Import do me_response_doc = { :id=>1000, :first_name=>"John", :last_name=>"Jones", :email=>"jjones@example.com" }.freeze dash_response_doc = { :id => 500, :title => "Original Dash", :description => "Description of the Dash", :slug => "123xyz", :folder_id => 1, :deleted => false, :dashboard_filters => [], :dashboard_elements => [], :dashboard_layouts => [] }.freeze operations = { :create_dashboard => { :info => { :parameters => [ { :in => "body", :schema => { :$ref=>"#/definitions/Dashboard" } } ] } }, :update_dashboard => { :info => { :parameters => [ { "name": "dashboard_id", "in": "path", "description": "Id of dashboard", "required": true, "type": "string" }, { :in => "body", :schema => { :$ref=>"#/definitions/Dashboard" } } ] } } }.freeze swagger = JSON.parse(<<-SWAGGER, {:symbolize_names => true}).freeze { "definitions": { "Dashboard": { "properties": { "title": { "type": "string", "description": "Look Title", "x-looker-nullable": true }, "description": { "type": "string", "description": "Description", "x-looker-nullable": true }, "hidden": { "type": "boolean", "description": "Is Hidden", "x-looker-nullable": false }, "refresh_interval": { "type": "string", "description": "Refresh Interval", "x-looker-nullable": true }, "load_configuration": { "type": "string", "x-looker-nullable": true }, "folder_id": { "type": "string", "description": "Id of Folder", "x-looker-nullable": true }, "show_title": { "type": "boolean", "description": "Show title", "x-looker-nullable": false }, "title_color": { "type": "string", "description": "Title color", "x-looker-nullable": true }, "show_filters_bar": { "type": "boolean", "x-looker-nullable": false }, "tile_background_color": { "type": "string", "description": "Tile background color", "x-looker-nullable": true }, "tile_text_color": { "type": "string", "description": "Tile text color", "x-looker-nullable": true }, "text_tile_text_color": { "type": "string", "description": "Color of text on text tiles", "x-looker-nullable": true }, "deleted": { "type": "boolean", "description": "Whether or not a dashboard is deleted.", "x-looker-nullable": false }, "query_timezone": { "type": "string", "description": "Timezone in which the Dashboard will run by default.", "x-looker-nullable": true } }, "x-looker-status": "beta" } } } SWAGGER define_method :mock_sdk do |block_hash={}| mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:operations) { operations } mock_sdk.define_singleton_method(:swagger) { swagger } mock_sdk.define_singleton_method(:me) do |req| HashResponse.new(me_response_doc) end mock_sdk.define_singleton_method(:create_dashboard) do |req| if block_hash && block_hash[:create_dashboard] block_hash[:create_dashboard].call(req) end doc = dash_response_doc.dup doc[:id] += 1 HashResponse.new(doc) end mock_sdk.define_singleton_method(:update_dashboard) do |id,req| if block_hash && block_hash[:update_dashboard] block_hash[:update_dashboard].call(id,req) end doc = dash_response_doc.dup doc.merge!(req) doc[:id] = id HashResponse.new(doc) end mock_sdk.define_singleton_method(:search_dashboards) do |req| if req&.fetch(:slug,nil) == dash_response_doc[:slug] && req&.fetch(:folder_id,nil) == dash_response_doc[:folder_id] [HashResponse.new(dash_response_doc)] elsif req&.fetch(:slug,nil) == dash_response_doc[:slug] && !req.has_key?(:folder_id) [HashResponse.new(dash_response_doc)] elsif "DeletedSlug".eql?(req&.fetch(:slug,nil)) && req[:deleted] doc = dash_response_doc.dup doc[:id] = 201 doc[:folder_id] = 2 doc[:slug] = "DeletedSlug" doc[:deleted] = true [HashResponse.new(doc)] elsif "dupe".eql?(req&.fetch(:slug,nil)) && !req.has_key?(:folder_id) doc = dash_response_doc.dup doc[:id] = 201 doc[:folder_id] = 2 doc[:slug] = "dupe" [HashResponse.new(doc)] elsif req&.fetch(:title,nil) == dash_response_doc[:title] && req&.fetch(:folder_id,nil) == dash_response_doc[:folder_id] [HashResponse.new(dash_response_doc)] else [] end end mock_sdk end it "executes `import` when no conflicting dashboards exist" do output = StringIO.new options = {} command = Gzr::Commands::Dashboard::Import.new(StringIO.new('{ "id": "101", "title": "New Dash", "description": "Description of the Dash", "dashboard_filters": [], "dashboard_elements": [], "dashboard_layouts": [] }'), 1, options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq("Imported dashboard 501\n") end it "executes `import` and gets exception when there is another dashboard of different name but same slug" do output = StringIO.new options = {} command = Gzr::Commands::Dashboard::Import.new(StringIO.new('{ "id": "101", "title": "New Dash", "slug": "123xyz", "description": "Description of the Dash", "dashboard_filters": [], "dashboard_elements": [], "dashboard_layouts": [] }'), 1, options) command.instance_variable_set(:@sdk, mock_sdk) expect { command.execute(output: output) }.to raise_error(/Use --force/) end it "executes `import` and gets exception when there is a deleted dashboard of different name but same slug" do output = StringIO.new options = {} command = Gzr::Commands::Dashboard::Import.new(StringIO.new('{ "id": "101", "title": "New Dash", "slug": "DeletedSlug", "description": "Description of the Dash", "dashboard_filters": [], "dashboard_elements": [], "dashboard_layouts": [] }'), 1, options) command.instance_variable_set(:@sdk, mock_sdk) expect { command.execute(output: output) }.to raise_error(/Use --force/) end it "executes `import` and gets exception when there is another dashboard of same name" do output = StringIO.new options = {} command = Gzr::Commands::Dashboard::Import.new(StringIO.new('{ "id": "101", "title": "Original Dash", "slug": "abc123", "description": "Description of the Dash", "dashboard_filters": [], "dashboard_elements": [], "dashboard_layouts": [] }'), 1, options) command.instance_variable_set(:@sdk, mock_sdk) expect { command.execute(output: output) }.to raise_error(/Use --force/) end it "executes `import` and succeeds with force when there is another dashboard of different name but same slug" do output = StringIO.new options = {:force=>true} command = Gzr::Commands::Dashboard::Import.new(StringIO.new('{ "id": "101", "title": "New Dash", "slug": "123xyz", "description": "Description of the Dash", "dashboard_filters": [], "dashboard_elements": [], "dashboard_layouts": [] }'), 1, options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to end_with("Imported dashboard 500\n") end it "executes `import` and succeeds with force when there is a deleted dashboard of different name but same slug" do output = StringIO.new options = {:force=>true} command = Gzr::Commands::Dashboard::Import.new(StringIO.new('{ "id": "101", "title": "New Dash", "slug": "DeletedSlug", "description": "Description of the Dash", "dashboard_filters": [], "dashboard_elements": [], "dashboard_layouts": [] }'), 1, options) block_hash = {:update_dashboard => Proc.new do |id,req| expect(req).not_to include(:deleted => true) end } command.instance_variable_set(:@sdk, mock_sdk(block_hash)) command.execute(output: output) expect(output.string).to end_with("Imported dashboard 201\n") end it "executes `import` and succeeds when there is a duplicate slug" do output = StringIO.new options = {} command = Gzr::Commands::Dashboard::Import.new(StringIO.new('{ "id": "101", "title": "New Dash", "slug": "dupe", "description": "Description of the Dash", "dashboard_filters": [], "dashboard_elements": [], "dashboard_layouts": [] }'), 1, options) block_hash = {:create_dashboard => Proc.new do |req| expect(req).not_to include(:slug => "dupe") expect(req).not_to include(:deleted => true) end } command.instance_variable_set(:@sdk, mock_sdk(block_hash)) command.execute(output: output) expect(output.string).to end_with("Imported dashboard 501\n") end it "executes `import` and succeeds with force when there is another dashboard of same name" do output = StringIO.new options = {:force=>true} command = Gzr::Commands::Dashboard::Import.new(StringIO.new('{ "id": "101", "title": "Original Dash", "slug": "abc123", "description": "Description of the Dash", "dashboard_filters": [], "dashboard_elements": [], "dashboard_layouts": [] }'), 1, options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to end_with("Imported dashboard 500\n") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/dashboard/mv_spec.rb
spec/unit/dashboard/mv_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/dashboard/mv' RSpec.describe Gzr::Commands::Dashboard::Mv do dash_response_doc = { :id => 500, :title => "Original Dash", :description => "Description of the Dash", :slug => "123xyz", :folder_id => 1, :deleted => false, :dashboard_filters => [], :dashboard_elements => [], :dashboard_layouts => [] }.freeze operations = { :update_dashboard => { :info => { :parameters => [ { "name": "dashboard_id", "in": "path", "description": "Id of dashboard", "required": true, "type": "string" }, { :in => "body", :schema => { :$ref=>"#/definitions/Dashboard" } } ] } } }.freeze define_method :mock_sdk do |block_hash={}| mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:operations) { operations } mock_sdk.define_singleton_method(:dashboard) do |id| if block_hash && block_hash[:dashboard] block_hash[:dashboard].call(id) end doc = dash_response_doc.dup HashResponse.new(doc) end mock_sdk.define_singleton_method(:update_dashboard) do |id,req| if block_hash && block_hash[:update_dashboard] block_hash[:update_dashboard].call(id,req) end doc = dash_response_doc.dup doc.merge!(req) HashResponse.new(doc) end mock_sdk.define_singleton_method(:search_dashboards) do |req| if req&.fetch(:folder_id,nil) == 2 && req&.fetch(:title,nil) == 'Original Dash' [] end end mock_sdk end it "executes `mv` when no conflicting dashboards exist" do output = StringIO.new options = {} command = Gzr::Commands::Dashboard::Mv.new(500, 2, options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq("Moved dashboard 500 to folder 2\n") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/dashboard/rm_spec.rb
spec/unit/dashboard/rm_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/dashboard/rm' RSpec.describe Gzr::Commands::Dashboard::Rm do it "executes `rm` command successfully" do mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:delete_dashboard) do |id| return end output = StringIO.new options = {} command = Gzr::Commands::Dashboard::Rm.new(1, options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq("") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/dashboard/cat_spec.rb
spec/unit/dashboard/cat_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/dashboard/cat' RSpec.describe Gzr::Commands::Dashboard::Cat do it "executes `dashboard cat` command successfully" do require 'sawyer' dashboard = { :id=>1, :title=>"foo", :dashboard_elements=>[], :dashboard_layouts=>[] , :dashboard_filters=>[] } mock_response = double(Sawyer::Resource, dashboard) allow(mock_response).to receive(:to_attrs).and_return(dashboard) mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:dashboard) do |dashboard_id| return mock_response end output = StringIO.new options = { dir: nil } command = Gzr::Commands::Dashboard::Cat.new(1,options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT { "id": 1, "title": "foo", "dashboard_elements": [ ], "dashboard_layouts": [ ], "dashboard_filters": [ ] } OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/folder/export_spec.rb
spec/unit/folder/export_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/folder/export' RSpec.describe Gzr::Commands::Folder::Export do me_response_doc = { :id=>1000, :first_name=>"John", :last_name=>"Jones", :email=>"jjones@example.com", :home_folder_id=>314159, :personal_folder_id=>1088 }.freeze mock_looks = [ {:id=>101, :folder_id=>2, :title=>"Look 101"}, {:id=>102, :folder_id=>2, :title=>"Look 102"}, {:id=>103, :folder_id=>3, :title=>"Look 103"}, {:id=>104, :folder_id=>3, :title=>"Look 104 with / in name"}, {:id=>105, :folder_id=>5, :title=>"Look 105"}, {:id=>106, :folder_id=>5, :title=>"Look 106 with / in name"} ] mock_dashboards = [ {:id=>201, :folder_id=>2, :title=>"Dash 201", :dashboard_elements=>[]}, {:id=>202, :folder_id=>2, :title=>"Dash 202", :dashboard_elements=>[]}, {:id=>203, :folder_id=>3, :title=>"Dash 203", :dashboard_elements=>[]}, {:id=>204, :folder_id=>3, :title=>"Dash 204 with / in name", :dashboard_elements=>[]}, {:id=>205, :folder_id=>5, :title=>"Dash 205", :dashboard_elements=>[]}, {:id=>206, :folder_id=>5, :title=>"Dash 206 with / in name", :dashboard_elements=>[]} ] mock_folders = Array.new mock_folders << { :id=>1, :name=>"Folder 1", :looks=>[ ], :dashboards=>[ ], :parent_id=>nil } mock_folders << { :id=>2, :name=>"Folder 2", :looks=>mock_looks.select {|l| l[:folder_id] == 2}.map{|l| HashResponse.new(l)}, :dashboards=>mock_dashboards.select {|d| d[:folder_id] == 2}.map{|d| HashResponse.new(d)}, :parent_id=>1 } mock_folders << { :id=>5, :name=>"Folder 5", :looks=>mock_looks.select {|l| l[:folder_id] == 5}.map{|l| HashResponse.new(l)}, :dashboards=>mock_dashboards.select {|d| d[:folder_id] == 5}.map{|d| HashResponse.new(d)}, :parent_id=>1 } mock_folders << { :id=>3, :name=>"Folder with / in name", :looks=>mock_looks.select {|l| l[:folder_id] == 3}.map{|l| HashResponse.new(l)}, :dashboards=>mock_dashboards.select {|d| d[:folder_id] == 3}.map{|d| HashResponse.new(d)}, :parent_id=>2 } mock_folders << { :id=>4, :name=>nil, :looks=>[], :dashboards=>[ ], :parent_id=>2 } define_method :mock_sdk do |block_hash={}| mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:me) do |req| HashResponse.new(me_response_doc) end mock_sdk.define_singleton_method(:search_folders) do |req| if block_hash && block_hash[:search_folders] block_hash[:search_folders].call(req) end doc = dash_response_doc.dup doc[:id] += 1 HashResponse.new(doc) end mock_sdk.define_singleton_method(:folder) do |id,req| if block_hash && block_hash[:folder] block_hash[:folder].call(id,req) end docs = mock_folders.select {|s| s[:id] == id} return HashResponse.new(docs.first) unless docs.empty? nil end mock_sdk.define_singleton_method(:look) do |id| if block_hash && block_hash[:look] block_hash[:look].call(id) end docs = mock_looks.select {|l| l[:id] == id} return HashResponse.new(docs.first) unless docs.empty? nil end mock_sdk.define_singleton_method(:dashboard) do |id| if block_hash && block_hash[:dashboard] block_hash[:dashboard].call(id) end docs = mock_dashboards.select {|d| d[:id] == id} return HashResponse.new(docs.first) unless docs.empty? nil end mock_sdk.define_singleton_method(:folder_children) do |id,req| if block_hash && block_hash[:folder_children] block_hash[:folder_children].call(id,req) end docs = mock_folders.select {|s| s[:parent_id] == id} return docs.map {|d| HashResponse.new(d)} end mock_sdk end require 'rubygems/package' it "executes `export` command successfully" do output = StringIO.new options = {} command = Gzr::Commands::Folder::Export.new(1,options) command.instance_variable_set(:@sdk, mock_sdk) mock_tar_writer = double(Gem::Package::TarWriter) mock_tar_writer.define_singleton_method(:mkdir) do |name,mode| output.puts "mkdir #{name},#{mode}" end mock_tar_writer.define_singleton_method(:add_file) do |name,mode| output.puts "add_file #{name},#{mode}" end command.process_folder(1,mock_tar_writer) expect(output.string).to eq <<-OUT mkdir Folder 1,493 add_file Folder 1/Folder_1_Folder 1.json,420 mkdir Folder 1/Folder 2,493 add_file Folder 1/Folder 2/Folder_2_Folder 2.json,420 add_file Folder 1/Folder 2/Look_101_Look 101.json,420 add_file Folder 1/Folder 2/Look_102_Look 102.json,420 add_file Folder 1/Folder 2/Dashboard_201_Dash 201.json,420 add_file Folder 1/Folder 2/Dashboard_202_Dash 202.json,420 mkdir Folder 1/Folder 2/Folder with ∕ in name,493 add_file Folder 1/Folder 2/Folder with ∕ in name/Folder_3_Folder with ∕ in name.json,420 add_file Folder 1/Folder 2/Folder with ∕ in name/Look_103_Look 103.json,420 add_file Folder 1/Folder 2/Folder with ∕ in name/Look_104_Look 104 with ∕ in name.json,420 add_file Folder 1/Folder 2/Folder with ∕ in name/Dashboard_203_Dash 203.json,420 add_file Folder 1/Folder 2/Folder with ∕ in name/Dashboard_204_Dash 204 with ∕ in name.json,420 mkdir Folder 1/Folder 2/nil (4),493 add_file Folder 1/Folder 2/nil (4)/Folder_4_nil (4).json,420 mkdir Folder 1/Folder 5,493 add_file Folder 1/Folder 5/Folder_5_Folder 5.json,420 add_file Folder 1/Folder 5/Look_105_Look 105.json,420 add_file Folder 1/Folder 5/Look_106_Look 106 with ∕ in name.json,420 add_file Folder 1/Folder 5/Dashboard_205_Dash 205.json,420 add_file Folder 1/Folder 5/Dashboard_206_Dash 206 with ∕ in name.json,420 OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/folder/ls_spec.rb
spec/unit/folder/ls_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/folder/ls' RSpec.describe Gzr::Commands::Folder::Ls do it "executes `folder ls` command successfully" do require 'sawyer' resp_hash = { :id=>1, :name=>"foo", :parent_id=>0, :looks=>[ { :id=>2, :title=>"bar" } ], :dashboards=>[ { :id=>3, :title=>"baz" } ] } mock_response = double(Sawyer::Resource, resp_hash) allow(mock_response).to receive(:to_attrs).and_return(resp_hash) mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:folder) do |look_id,req| return mock_response end resp_hash2 = { :id=>4, :name=>"buz", :parent_id=>1 } mock_response2 = double(Sawyer::Resource, resp_hash2) allow(mock_response2).to receive(:to_attrs).and_return(resp_hash2) mock_sdk.define_singleton_method(:folder_children) do |look_id,req| return [mock_response2] end output = StringIO.new options = { :fields=>'parent_id,id,name,looks(id,title),dashboards(id,title)' } command = Gzr::Commands::Folder::Ls.new("1", options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT +---------+--+----+--------+-----------+-------------+----------------+ |parent_id|id|name|looks.id|looks.title|dashboards.id|dashboards.title| +---------+--+----+--------+-----------+-------------+----------------+ | 0| 1|foo | | | | | | 1| 4|buz | | | | | | | | | 2|bar | | | | | | | | | 3|baz | +---------+--+----+--------+-----------+-------------+----------------+ OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/folder/top_spec.rb
spec/unit/folder/top_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/folder/top' RSpec.describe Gzr::Commands::Folder::Top do it "executes `top` command successfully" do require 'sawyer' mock_folders = Array.new (1..6).each do |i| h = { :id=>i, :name=>"Folder #{i}", :is_shared_root=>i==1, :is_users_root=>i==2, :is_embed_shared_root=>i==5, :is_embed_users_root=>i==5, } m = double(Sawyer::Resource, h) allow(m).to receive(:to_attrs).and_return(h) allow(m).to receive(:name).and_return(h[:name]) allow(m).to receive(:is_shared_root).and_return(h[:is_shared_root]) allow(m).to receive(:is_users_root).and_return(h[:is_users_root]) allow(m).to receive(:is_embed_shared_root).and_return(h[:is_embed_shared_root]) allow(m).to receive(:is_embed_users_root).and_return(h[:is_embed_users_root]) mock_folders << m end mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:all_folders) do |body| return mock_folders end output = StringIO.new options = {:fields => 'id,name,is_shared_root,is_users_root,is_embed_shared_root,is_embed_users_root'} options[:width] = 130 command = Gzr::Commands::Folder::Top.new(options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT +--+--------+--------------+-------------+--------------------+-------------------+ |id|name |is_shared_root|is_users_root|is_embed_shared_root|is_embed_users_root| +--+--------+--------------+-------------+--------------------+-------------------+ | 1|Folder 1|true |false |false |false | | 2|Folder 2|false |true |false |false | | 5|Folder 5|false |false |true |true | +--+--------+--------------+-------------+--------------------+-------------------+ OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/folder/create_spec.rb
spec/unit/folder/create_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/folder/create' RSpec.describe Gzr::Commands::Folder::Create do it "executes `create` command successfully" do require 'sawyer' resp_hash = { :id=>1, :name=>"foo", :parent_id=>0, :looks=>[ { :id=>2, :title=>"bar" } ], :dashboards=>[ { :id=>3, :title=>"baz" } ] } mock_response = double(Sawyer::Resource, resp_hash) allow(mock_response).to receive(:to_attrs).and_return(resp_hash) mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:create_folder) do |req| return mock_response end output = StringIO.new options = {} command = Gzr::Commands::Folder::Create.new("new folder", 1, options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq("Created folder 1\n") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/folder/tree_spec.rb
spec/unit/folder/tree_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/folder/tree' RSpec.describe Gzr::Commands::Folder::Tree do me_response_doc = { :id=>1000, :first_name=>"John", :last_name=>"Jones", :email=>"jjones@example.com", :home_folder_id=>314159, :personal_folder_id=>1088 }.freeze mock_folders = Array.new mock_folders << { :id=>1, :name=>"Folder 1", :looks=>[ ], :dashboards=>[ ], :parent_id=>nil } mock_folders << { :id=>2, :name=>"Folder 2", :looks=>[ HashResponse.new({:id=>101, :title=>"Look 101"}), HashResponse.new({:id=>102, :title=>"Look 102"}) ], :dashboards=>[ HashResponse.new({:id=>201, :title=>"Dash 201"}), HashResponse.new({:id=>202, :title=>"Dash 202"}) ], :parent_id=>1 } mock_folders << { :id=>5, :name=>"Folder 5", :looks=>[ HashResponse.new({:id=>105, :title=>"Look 105"}), HashResponse.new({:id=>106, :title=>"Look 106 with / in name"}) ], :dashboards=>[ HashResponse.new({:id=>205, :title=>"Dash 205"}), HashResponse.new({:id=>206, :title=>"Dash 206 with / in name"}) ], :parent_id=>1 } mock_folders << { :id=>3, :name=>"Folder with / in name", :looks=>[ HashResponse.new({:id=>103, :title=>"Look 103"}), HashResponse.new({:id=>104, :title=>"Look 104 with / in name"}) ], :dashboards=>[ HashResponse.new({:id=>203, :title=>"Dash 203"}), HashResponse.new({:id=>204, :title=>"Dash 204 with / in name"}) ], :parent_id=>2 } mock_folders << { :id=>4, :name=>nil, :looks=>[], :dashboards=>[ ], :parent_id=>2 } define_method :mock_sdk do |block_hash={}| mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:me) do |req| HashResponse.new(me_response_doc) end mock_sdk.define_singleton_method(:search_folders) do |req| if block_hash && block_hash[:search_folders] block_hash[:search_folders].call(req) end doc = dash_response_doc.dup doc[:id] += 1 HashResponse.new(doc) end mock_sdk.define_singleton_method(:folder) do |id,req| if block_hash && block_hash[:folder] block_hash[:folder].call(id,req) end docs = mock_folders.select {|s| s[:id] == id} return HashResponse.new(docs.first) unless docs.empty? nil end mock_sdk.define_singleton_method(:folder_children) do |id,req| if block_hash && block_hash[:folder_children] block_hash[:folder_children].call(id,req) end docs = mock_folders.select {|s| s[:parent_id] == id} return docs.map {|d| HashResponse.new(d)} end mock_sdk end it "executes `tree` command successfully" do output = StringIO.new options = {} command = Gzr::Commands::Folder::Tree.new("1",options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT Folder 1 └── Folder 2 ├── Folder with / in name │ ├── (l) Look 103 │ ├── (l) Look 104 with / in name │ ├── (d) Dash 203 │ └── (d) Dash 204 with / in name ├── nil (4) ├── (l) Look 101 ├── (l) Look 102 ├── (d) Dash 201 └── (d) Dash 202 └── Folder 5 ├── (l) Look 105 ├── (l) Look 106 with / in name ├── (d) Dash 205 └── (d) Dash 206 with / in name OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/folder/rm_spec.rb
spec/unit/folder/rm_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/folder/rm' RSpec.describe Gzr::Commands::Folder::Rm do it "executes `rm` command successfully" do require 'sawyer' response_doc = { :dashboards=>[], :looks=>[] } mock_response = double(Sawyer::Resource, response_doc) allow(mock_response).to receive(:to_attrs).and_return(response_doc) mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:folder) do |id, req| return mock_response end mock_sdk.define_singleton_method(:folder_children) do |id, req| return [] end mock_sdk.define_singleton_method(:delete_folder) do |id| return nil end output = StringIO.new options = {} command = Gzr::Commands::Folder::Rm.new(1, options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq("") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/folder/cat_spec.rb
spec/unit/folder/cat_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/folder/cat' RSpec.describe Gzr::Commands::Folder::Cat do it "executes `cat` command successfully" do require 'sawyer' resp_hash = { :id=>1, :name=>"foo", :parent_id=>0, :looks=>[ { :id=>2, :title=>"bar" } ], :dashboards=>[ { :id=>3, :title=>"baz" } ] } mock_response = double(Sawyer::Resource, resp_hash) allow(mock_response).to receive(:to_attrs).and_return(resp_hash) mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:folder) do |look_id,req| return mock_response end output = StringIO.new options = {} command = Gzr::Commands::Folder::Cat.new("1", options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT { "id": 1, "name": "foo", "parent_id": 0, "looks": [ { "id": 2, "title": "bar" } ], "dashboards": [ { "id": 3, "title": "baz" } ] } OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/look/import_spec.rb
spec/unit/look/import_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/look/import' RSpec.describe Gzr::Commands::Look::Import do me_response_doc = { :id=>1000, :first_name=>"John", :last_name=>"Jones", :email=>"jjones@example.com" }.freeze query_response_doc = { :id=>555 }.freeze look_response_doc = { :id => 31415, :title => "Daily Profit", :description => "Total profit by day for the last 100 days", :query_id => 555, :user_id => 1000, :folder_id => 1, :slug => "123xyz" }.freeze operations = { :create_query => { :info => { :parameters => [ { :in => "body", :schema => { :$ref=>"#/definitions/Query" } } ] } }, :create_look => { :info => { :parameters => [ { :in => "body", :schema => { :$ref=>"#/definitions/Look" } } ] } }, :update_look => { :info => { :parameters => [ { "name": "look_id", "in": "path", "description": "Id of look", "required": true, "type": "integer", "format": "int64" }, { :in => "body", :schema => { :$ref=>"#/definitions/Look" } } ] } } }.freeze swagger = JSON.parse(<<-SWAGGER, {:symbolize_names => true}).freeze { "definitions": { "Query": { "properties": { "model": { "type": "string", "description": "Model", "x-looker-nullable": false }, "view": { "type": "string", "description": "View", "x-looker-nullable": false }, "fields": { "type": "array", "items": { "type": "string" }, "description": "Fields", "x-looker-nullable": true }, "pivots": { "type": "array", "items": { "type": "string" }, "description": "Pivots", "x-looker-nullable": true }, "fill_fields": { "type": "array", "items": { "type": "string" }, "description": "Fill Fields", "x-looker-nullable": true }, "filters": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Filters", "x-looker-nullable": true }, "filter_expression": { "type": "string", "description": "Filter Expression", "x-looker-nullable": true }, "sorts": { "type": "array", "items": { "type": "string" }, "x-looker-nullable": true }, "limit": { "type": "string", "description": "Limit", "x-looker-nullable": true }, "column_limit": { "type": "string", "description": "Column Limit", "x-looker-nullable": true }, "total": { "type": "boolean", "description": "Total", "x-looker-nullable": false }, "row_total": { "type": "string", "description": "Raw Total", "x-looker-nullable": true }, "runtime": { "type": "number", "format": "double", "description": "Runtime", "x-looker-nullable": true }, "vis_config": { "type": "object", "additionalProperties": { "type": "string", "format": "any" }, "x-looker-nullable": true }, "filter_config": { "type": "object", "additionalProperties": { "type": "string", "format": "any" }, "x-looker-nullable": true }, "visible_ui_sections": { "type": "string", "description": "Visible UI Sections", "x-looker-nullable": true }, "dynamic_fields": { "type": "array", "items": { "type": "string", "format": "any" }, "description": "Dynamic Fields", "x-looker-nullable": true }, "client_id": { "type": "string", "x-looker-nullable": true }, "query_timezone": { "type": "string", "description": "Query Timezone", "x-looker-nullable": true } }, "x-looker-status": "stable", "required": [ "model", "view" ] }, "Look": { "properties": { "title": { "type": "string", "description": "Look Title", "x-looker-nullable": true }, "query_id": { "type": "integer", "format": "int64", "description": "Query Id", "x-looker-nullable": true }, "description": { "type": "string", "description": "Description", "x-looker-nullable": true }, "user_id": { "type": "integer", "format": "int64", "description": "User Id", "x-looker-nullable": true }, "folder_id": { "type": "string", "description": "Folder Id", "x-looker-nullable": true } }, "x-looker-status": "beta" } } } SWAGGER define_method :mock_sdk do |block_hash={}| mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:operations) { operations } mock_sdk.define_singleton_method(:swagger) { swagger } mock_sdk.define_singleton_method(:me) do |req| HashResponse.new(me_response_doc) end mock_sdk.define_singleton_method(:create_query) do |req| if block_hash && block_hash[:create_query] block_hash[:create_query].call(req) end doc = query_response_doc.dup doc[:id] += 1 HashResponse.new(doc) end mock_sdk.define_singleton_method(:create_look) do |req| if block_hash && block_hash[:create_look] block_hash[:create_look].call(req) end doc = look_response_doc.dup doc.merge!(req) doc[:id] += 1 HashResponse.new(doc) end mock_sdk.define_singleton_method(:update_look) do |id,req| if block_hash && block_hash[:update_look] block_hash[:update_look].call(id,req) end doc = look_response_doc.dup doc.merge!(req) doc[:id] = id HashResponse.new(doc) end mock_sdk.define_singleton_method(:search_looks) do |req| if req&.fetch(:slug,nil) == look_response_doc[:slug] && req&.fetch(:folder_id,nil) == look_response_doc[:folder_id] [HashResponse.new(look_response_doc)] elsif req&.fetch(:slug,nil) == look_response_doc[:slug] && !req.has_key?(:folder_id) [HashResponse.new(look_response_doc)] elsif "DeletedSlug".eql?(req&.fetch(:slug,nil)) && req[:deleted] doc = look_response_doc.dup doc[:id] = 201 doc[:folder_id] = 2 doc[:slug] = "DeletedSlug" doc[:deleted] = true [HashResponse.new(doc)] elsif "dupe".eql?(req&.fetch(:slug,nil)) && !req.has_key?(:folder_id) doc = look_response_doc.dup doc[:id] = 201 doc[:folder_id] = 2 doc[:slug] = "dupe" [HashResponse.new(doc)] elsif req&.fetch(:title,nil) == look_response_doc[:title] && req&.fetch(:folder_id,nil) == look_response_doc[:folder_id] [HashResponse.new(look_response_doc)] else [] end end mock_sdk end it "executes `import` command successfully" do output = StringIO.new file = nil options = {} command = Gzr::Commands::Look::Import.new(StringIO.new( <<-LOOK { "id": 198, "query_id": 90961, "title": "New Look", "query": { "id": 90961, "view": "order_items", "fields": [ "orders.created_date", "orders.total_profit" ], "sorts": [ "orders.created_date desc" ], "limit": "500", "column_limit": "50", "total": null, "row_total": null, "model": "ecommerce" }, "model": { "id": "ecommerce", "label": "Ecommerce" }, "deleted": false, "public": null } LOOK ), 1, options) block_hash = {:create_look => Proc.new do |req| expect(req).not_to include(:deleted => true) expect(req).to include(:folder_id => 1) end } command.instance_variable_set(:@sdk, mock_sdk(block_hash)) command.execute(output: output) expect(output.string).to eq("Imported look 31416\n") end it "executes `import` command successfully with conflicting slug" do output = StringIO.new file = nil options = {} command = Gzr::Commands::Look::Import.new(StringIO.new( <<-LOOK { "id": 198, "slug": "dupe", "query_id": 90961, "title": "New Look", "query": { "id": 90961, "view": "order_items", "fields": [ "orders.created_date", "orders.total_profit" ], "sorts": [ "orders.created_date desc" ], "limit": "500", "column_limit": "50", "total": null, "row_total": null, "model": "ecommerce" }, "model": { "id": "ecommerce", "label": "Ecommerce" }, "deleted": false, "public": null } LOOK ), 1, options) block_hash = {:create_look => Proc.new do |req| expect(req).not_to include(:deleted => true) expect(req).to include(:folder_id => 1) expect(req).not_to include(:slug) end } command.instance_variable_set(:@sdk, mock_sdk(block_hash)) command.execute(output: output) expect(output.string).to end_with("Imported look 31416\n") end it "executes `import` command and gets exception with conflicting name" do output = StringIO.new file = nil options = {} command = Gzr::Commands::Look::Import.new(StringIO.new( <<-LOOK { "id": 198, "query_id": 90961, "title": "Daily Profit", "query": { "id": 90961, "view": "order_items", "fields": [ "orders.created_date", "orders.total_profit" ], "sorts": [ "orders.created_date desc" ], "limit": "500", "column_limit": "50", "total": null, "row_total": null, "model": "ecommerce" }, "model": { "id": "ecommerce", "label": "Ecommerce" }, "deleted": false, "public": null } LOOK ), 1, options) command.instance_variable_set(:@sdk, mock_sdk) expect { command.execute(output: output) }.to raise_error(/Use --force/) end it "executes `import` command with conflicting name and succeeds with force flag" do output = StringIO.new file = nil options = {:force=>true} command = Gzr::Commands::Look::Import.new(StringIO.new( <<-LOOK { "id": 198, "query_id": 90961, "title": "Daily Profit", "folder_id": "1", "query": { "id": 90961, "view": "order_items", "fields": [ "orders.created_date", "orders.total_profit" ], "sorts": [ "orders.created_date desc" ], "limit": "500", "column_limit": "50", "total": null, "row_total": null, "model": "ecommerce" }, "model": { "id": "ecommerce", "label": "Ecommerce" }, "deleted": false, "public": null } LOOK ), 1, options) block_hash = {:update_look => Proc.new do |i,req| expect(i).to eq(31415) expect(req).not_to include(:deleted => true) expect(req).not_to include(:folder_id) expect(req).not_to include(:slug) end } command.instance_variable_set(:@sdk, mock_sdk(block_hash)) command.execute(output: output) expect(output.string).to end_with("Imported look 31415\n") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/look/mv_spec.rb
spec/unit/look/mv_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/look/mv' RSpec.describe Gzr::Commands::Look::Mv do look_response_doc = { :id=>31415, :title=>"Daily Profit", :description=>"Total profit by day for the last 100 days", :query_id=>555, :user_id=>1000, :folder_id=>1, :slug=>"123xyz" }.freeze define_method :mock_sdk do |block_hash={}| mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:look) do |id| if block_hash && block_hash[:look] block_hash[:look].call(id) end doc = look_response_doc.dup HashResponse.new(doc) end mock_sdk.define_singleton_method(:update_look) do |id,req| if block_hash && block_hash[:update_look] block_hash[:update_look].call(id,req) end doc = look_response_doc.dup doc.merge!(req) HashResponse.new(doc) end mock_sdk.define_singleton_method(:search_looks) do |req| if req&.fetch(:folder_id,nil) == 2 && req&.fetch(:title,nil) == "Daily Profit" [] else [] end end mock_sdk end it "executes `look mv` command successfully" do output = StringIO.new options = {} command = Gzr::Commands::Look::Mv.new(31415,2,options) command.instance_variable_set(:@sdk, mock_sdk()) command.execute(output: output) expect(output.string).to eq("Moved look 31415 to folder 2\n") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/look/rm_spec.rb
spec/unit/look/rm_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/look/rm' RSpec.describe Gzr::Commands::Look::Rm do it "executes `rm` command successfully" do mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:delete_look) do |id| return end output = StringIO.new look_id = nil options = {} command = Gzr::Commands::Look::Rm.new(look_id, options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq("") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/look/cat_spec.rb
spec/unit/look/cat_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/look/cat' RSpec.describe Gzr::Commands::Look::Cat do it "executes `look cat` command successfully" do require 'sawyer' mock_response = double(Sawyer::Resource, { :id=>1, :title=>"foo" }) allow(mock_response).to receive(:to_attrs).and_return({ :id=>1, :title=>"foo" }) mock_sdk = Object.new mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:look) do |look_id| return mock_response end output = StringIO.new options = {} command = Gzr::Commands::Look::Cat.new(1,options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT { "id": 1, "title": "foo" } OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/role/group_add_spec.rb
spec/unit/role/group_add_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/role/group_add' RSpec.describe Gzr::Commands::Role::GroupAdd do it "executes `role group_add` command successfully" do require 'sawyer' groups = (100..105).collect do |i| group_doc = { :id=>i } mock_group = double(Sawyer::Resource, group_doc) allow(mock_group).to receive(:to_attrs).and_return(group_doc) mock_group end mock_sdk = Object.new allow(mock_sdk).to receive(:logout) allow(mock_sdk).to receive(:role_groups) do |role_id,body| groups end allow(mock_sdk).to receive(:set_role_groups) do |role_id,body| expect(body).to contain_exactly(100, 101, 102, 103, 104, 105, 106) nil end output = StringIO.new options = {} command = Gzr::Commands::Role::GroupAdd.new(1,[106],options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq("") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/role/group_rm_spec.rb
spec/unit/role/group_rm_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/role/group_rm' RSpec.describe Gzr::Commands::Role::GroupRm do it "executes `role group_rm` command successfully" do require 'sawyer' groups = (100..105).collect do |i| group_doc = { :id=>i } mock_group = double(Sawyer::Resource, group_doc) allow(mock_group).to receive(:to_attrs).and_return(group_doc) mock_group end mock_sdk = Object.new allow(mock_sdk).to receive(:logout) allow(mock_sdk).to receive(:role_groups) do |role_id,body| groups end allow(mock_sdk).to receive(:set_role_groups) do |role_id,body| expect(body).to contain_exactly(100, 101, 102, 104, 105) nil end output = StringIO.new options = {} command = Gzr::Commands::Role::GroupRm.new(1, [103], options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq("") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/role/user_ls_spec.rb
spec/unit/role/user_ls_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/role/user_ls' RSpec.describe Gzr::Commands::Role::UserLs do it "executes `role user_ls` command successfully" do require 'sawyer' users = (100..105).collect do |i| user_doc = { :id=>i, :first_name=>'User', :last_name=>"No#{i}", :email=>"User.No#{i}@example.com", } mock_user = double(Sawyer::Resource, user_doc) allow(mock_user).to receive(:to_attrs).and_return(user_doc) mock_user end mock_sdk = Object.new allow(mock_sdk).to receive(:logout) allow(mock_sdk).to receive(:role_users) do |role_id,body| users end output = StringIO.new options = { :fields=>'id,first_name,last_name,email' } command = Gzr::Commands::Role::UserLs.new(1,options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT +---+----------+---------+----------------------+ | id|first_name|last_name|email | +---+----------+---------+----------------------+ |100|User |No100 |User.No100@example.com| |101|User |No101 |User.No101@example.com| |102|User |No102 |User.No102@example.com| |103|User |No103 |User.No103@example.com| |104|User |No104 |User.No104@example.com| |105|User |No105 |User.No105@example.com| +---+----------+---------+----------------------+ OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/role/ls_spec.rb
spec/unit/role/ls_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/role/ls' RSpec.describe Gzr::Commands::Role::Ls do it "executes `role ls` command successfully" do require 'sawyer' roles = (100..105).collect do |i| role_doc = { :id=>i, :name=>"Role #{i}" } mock_role = double(Sawyer::Resource, role_doc) allow(mock_role).to receive(:to_attrs).and_return(role_doc) mock_role end mock_sdk = Object.new allow(mock_sdk).to receive(:logout) allow(mock_sdk).to receive(:all_roles) do |body| roles end output = StringIO.new options = { :fields=>'id,name' } command = Gzr::Commands::Role::Ls.new(options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT +---+--------+ | id|name | +---+--------+ |100|Role 100| |101|Role 101| |102|Role 102| |103|Role 103| |104|Role 104| |105|Role 105| +---+--------+ OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/role/user_rm_spec.rb
spec/unit/role/user_rm_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/role/user_rm' RSpec.describe Gzr::Commands::Role::UserRm do it "executes `role user_rm` command successfully" do require 'sawyer' users = (100..105).collect do |i| user_doc = { :id=>i } mock_user = double(Sawyer::Resource, user_doc) allow(mock_user).to receive(:to_attrs).and_return(user_doc) mock_user end mock_sdk = Object.new allow(mock_sdk).to receive(:logout) allow(mock_sdk).to receive(:role_users) do |role_id,body| users end allow(mock_sdk).to receive(:set_role_users) do |role_id,body| expect(body).to contain_exactly(100, 101, 102, 104, 105) nil end output = StringIO.new options = {} command = Gzr::Commands::Role::UserRm.new(1,[103],options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq("") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/role/group_ls_spec.rb
spec/unit/role/group_ls_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/role/group_ls' RSpec.describe Gzr::Commands::Role::GroupLs do it "executes `role group_ls` command successfully" do require 'sawyer' groups = (100..105).collect do |i| group_doc = { :id=>i, :name=>"Group No#{i}", } mock_group = double(Sawyer::Resource, group_doc) allow(mock_group).to receive(:to_attrs).and_return(group_doc) mock_group end mock_sdk = Object.new allow(mock_sdk).to receive(:logout) allow(mock_sdk).to receive(:role_groups) do |role_id,body| groups end output = StringIO.new options = { :fields=>'id,name' } command = Gzr::Commands::Role::GroupLs.new(1,options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT +---+-----------+ | id|name | +---+-----------+ |100|Group No100| |101|Group No101| |102|Group No102| |103|Group No103| |104|Group No104| |105|Group No105| +---+-----------+ OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/role/user_add_spec.rb
spec/unit/role/user_add_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/role/user_add' RSpec.describe Gzr::Commands::Role::UserAdd do it "executes `role user_add` command successfully" do require 'sawyer' users = (100..105).collect do |i| user_doc = { :id=>i } mock_user = double(Sawyer::Resource, user_doc) allow(mock_user).to receive(:to_attrs).and_return(user_doc) mock_user end mock_sdk = Object.new allow(mock_sdk).to receive(:logout) allow(mock_sdk).to receive(:role_users) do |role_id,body| users end allow(mock_sdk).to receive(:set_role_users) do |role_id,body| expect(body).to contain_exactly(100, 101, 102, 103, 104, 105, 106) nil end output = StringIO.new options = {} command = Gzr::Commands::Role::UserAdd.new(1,[106],options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq("") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/role/rm_spec.rb
spec/unit/role/rm_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/role/rm' RSpec.describe Gzr::Commands::Role::Rm do it "executes `role rm` command successfully" do require 'sawyer' mock_sdk = Object.new allow(mock_sdk).to receive(:logout) allow(mock_sdk).to receive(:delete_role) do |role_id,body| nil end output = StringIO.new options = {} command = Gzr::Commands::Role::Rm.new(1,options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq("") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/role/cat_spec.rb
spec/unit/role/cat_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/role/cat' RSpec.describe Gzr::Commands::Role::Cat do it "executes `role cat` command successfully" do require 'sawyer' role_doc = <<-DOC { "id": 100, "name": "Mock Role", "permission_set": { "id": 2, "name": "Developer", "permissions": [ "access_data", "create_table_calculations", "deploy", "develop", "download_without_limit", "explore", "manage_folders", "save_content", "schedule_look_emails", "see_lookml", "see_lookml_dashboards", "see_looks", "see_sql", "see_user_dashboards", "use_sql_runner" ], "built_in": false, "all_access": false, "url": "https://localhost:19999/api/3.0/permission_sets/2", "can": { } }, "model_set": { "id": 80, "name": "mock_modelset", "models": [ "mock_model" ], "built_in": false, "all_access": false, "url": "https://localhost:19999/api/3.0/model_sets/80", "can": { } }, "url": "https://localhost:19999/api/3.0/roles/100", "users_url": "https://localhost:19999/api/3.0/roles/100/users", "can": { "show": true, "index": true, "update": true } } DOC role_json = JSON.parse(role_doc) mock_role = double(Sawyer::Resource, role_json) allow(mock_role).to receive(:to_attrs).and_return(role_json) mock_sdk = Object.new allow(mock_sdk).to receive(:logout) allow(mock_sdk).to receive(:role) do |role_id,body| mock_role end output = StringIO.new options = {} command = Gzr::Commands::Role::Cat.new(100,options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq role_doc end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/attribute/set_group_value_spec.rb
spec/unit/attribute/set_group_value_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/attribute/set_group_value' RSpec.describe Gzr::Commands::Attribute::SetGroupValue do groups = [ { :id=>1, :name=>"group_1" }.freeze, { :id=>2, :name=>"group_2" }.freeze, { :id=>3, :name=>"group_3" }.freeze ] attrs = [ { :id=>1, :name=>"attribute_1", :label=>"Attribute 1", :type=>"string", :default_value=>nil, :is_system=>true, :is_permanent=>nil, :value_is_hidden=>false, :user_can_view=>true, :user_can_edit=>true, :hidden_value_domain_whitelist=>nil }.freeze, { :id=>2, :name=>"attribute_2", :label=>"Attribute 2", :type=>"number", :default_value=>5, :is_system=>false, :is_permanent=>nil, :value_is_hidden=>false, :user_can_view=>true, :user_can_edit=>true, :hidden_value_domain_whitelist=>nil }.freeze, { :id=>3, :name=>"attribute_3", :label=>"Attribute 3", :type=>"string", :default_value=>nil, :is_system=>false, :is_permanent=>nil, :value_is_hidden=>false, :user_can_view=>true, :user_can_edit=>false, :hidden_value_domain_whitelist=>nil }.freeze ] define_method :mock_sdk do |block_hash={}| mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:operations) { operations } mock_sdk.define_singleton_method(:swagger) { swagger } mock_sdk.define_singleton_method(:group) do |id,req| if block_hash && block_hash[:group] block_hash[:group].call(id,req) end found = groups.select {|a| a[:id] == id.to_i } return HashResponse.new(found.first) if found && !found.empty? nil end mock_sdk.define_singleton_method(:search_groups) do |req| if block_hash && block_hash[:search_groups] block_hash[:search_groups].call(req) end found = groups.select {|a| a[:name] == req[:name] } return nil if found.nil? || found.empty? found.map{|a| HashResponse.new(a)} end mock_sdk.define_singleton_method(:all_user_attributes) do |req| if block_hash && block_hash[:all_user_attributes] block_hash[:all_user_attributes].call(req) end attrs.map {|a| HashResponse.new(a)} end mock_sdk.define_singleton_method(:user_attribute) do |id,req| if block_hash && block_hash[:user_attribute] block_hash[:user_attribute].call(id,req) end found = attrs.select {|a| a[:id] == id.to_i } return HashResponse.new(found.first) if found && !found.empty? nil end mock_sdk.define_singleton_method(:update_user_attribute_group_value) do |group_id,attr_id,req| if block_hash && block_hash[:update_user_attribute_group_value] block_hash[:update_user_attribute_group_value].call(group_id,attr_id,req) end found_attrs = attrs.select {|a| a[:id] == attr_id.to_i } return nil if found_attrs.nil? || found_attrs.empty? found_groups = groups.select {|g| g[:id] == group_id.to_i } return nil if found_groups.nil? || found_groups.empty? resp = { :id=>1, :group_id=>found_groups.first[:id], :user_attribute_id=>found_attrs.first[:id], :value=>req[:value] } HashResponse.new(resp) end mock_sdk end it "executes `attribute set_group_value` command successfully with ids" do output = StringIO.new options = {} command = Gzr::Commands::Attribute::SetGroupValue.new("1","3","foo",options) command.instance_variable_set(:@sdk, mock_sdk()) command.execute(output: output) expect(output.string).to eq("Group attribute 1 set to foo\n") end it "executes `attribute set_group_value` command successfully with names" do output = StringIO.new options = {} command = Gzr::Commands::Attribute::SetGroupValue.new("group_3","attribute_2","foo",options) command.instance_variable_set(:@sdk, mock_sdk()) command.execute(output: output) expect(output.string).to eq("Group attribute 1 set to foo\n") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/attribute/import_spec.rb
spec/unit/attribute/import_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/attribute/import' RSpec.describe Gzr::Commands::Attribute::Import do attrs = [ { :id => 1, :name => "attribute_1", :label => "Attribute 1", :type => "string", :default_value => nil, :is_system => true, :is_permanent => nil, :value_is_hidden => false, :user_can_view => true, :user_can_edit => true, :hidden_value_domain_whitelist => nil }.freeze, { :id => 2, :name => "attribute_2", :label => "Attribute 2", :type => "number", :default_value => 5, :is_system => false, :is_permanent => nil, :value_is_hidden => false, :user_can_view => true, :user_can_edit => true, :hidden_value_domain_whitelist => nil }.freeze, { :id => 3, :name => "attribute_3", :label => "Attribute 3", :type => "string", :default_value => nil, :is_system => false, :is_permanent => nil, :value_is_hidden => false, :user_can_view => true, :user_can_edit => false, :hidden_value_domain_whitelist => nil }.freeze ] operations = { :create_user_attribute => { :info => { :parameters => [ { :in => "body", :schema => { :$ref=>"#/definitions/UserAttribute" } } ] } }, :update_user_attribute => { :info => { :parameters => [ { "name": "user_attribute_id", "in": "path", "description": "Id of user attribute", "required": true, "type": "integer", "format": "int64" }, { :in => "body", :schema => { :$ref=>"#/definitions/UserAttribute" } } ] } } }.freeze swagger = JSON.parse(<<-SWAGGER, {:symbolize_names => true}).freeze { "definitions": { "UserAttribute": { "properties": { "id": { "type": "integer", "format": "int64", "readOnly": true, "description": "Unique Id", "x-looker-nullable": false }, "name": { "type": "string", "description": "Name of user attribute", "x-looker-nullable": true }, "label": { "type": "string", "description": "Human-friendly label for user attribute", "x-looker-nullable": true }, "type": { "type": "string", "description": "Type of user attribute", "x-looker-nullable": true }, "default_value": { "type": "string", "description": "Default value for when no value is set on the user", "x-looker-nullable": true }, "is_system": { "type": "boolean", "readOnly": true, "description": "Attribute is a system default", "x-looker-nullable": false }, "user_can_view": { "type": "boolean", "description": "Non-admin users can see the values of their attributes and use them in filters", "x-looker-nullable": false }, "user_can_edit": { "type": "boolean", "description": "Users can change the value of this attribute for themselves", "x-looker-nullable": false } }, "x-looker-status": "stable" } } } SWAGGER define_method :mock_sdk do |block_hash={}| mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:operations) { operations } mock_sdk.define_singleton_method(:swagger) { swagger } mock_sdk.define_singleton_method(:all_user_attributes) do |req| if block_hash && block_hash[:all_user_attributes] block_hash[:all_user_attributes].call(req) end attrs.map {|a| HashResponse.new(a)} end mock_sdk.define_singleton_method(:user_attribute) do |id,req| if block_hash && block_hash[:user_attribute] block_hash[:user_attribute].call(id,req) end found = attrs.select {|a| a[:id] == id.to_i } return HashResponse.new(found.first) if found && !found.empty? nil end mock_sdk.define_singleton_method(:create_user_attribute) do |req| if block_hash && block_hash[:create_user_attribute] block_hash[:create_user_attribute].call(id) end req[:id] = 4 HashResponse.new(req) end mock_sdk.define_singleton_method(:update_user_attribute) do |id,req| if block_hash && block_hash[:update_user_attribute] block_hash[:update_user_attribute].call(id,req) end found = attrs.select {|a| a[:id] == id.to_i } return HashResponse.new(found.first.merge(req)) if found && !found.empty? nil end mock_sdk end it "executes `attribute import` command successfully for a new attribute" do output = StringIO.new options = {} command = Gzr::Commands::Attribute::Import.new(StringIO.new( <<-DOC ),options) { "name": "attribute_4", "label": "Attribute 4", "type": "string", "default_value": null, "is_system": false, "is_permanent": null, "value_is_hidden": false, "user_can_view": true, "user_can_edit": true, "hidden_value_domain_whitelist": null, "can": { "show": true, "index": true, "create": true, "show_value": true, "update": true, "destroy": true, "set_value": true } } DOC command.instance_variable_set(:@sdk, mock_sdk()) command.execute(output: output) expect(output.string).to eq <<-OUT Imported attribute attribute_4 4 OUT end it "executes `attribute import` command successfully with an existing attribute" do output = StringIO.new options = {:force => true} command = Gzr::Commands::Attribute::Import.new(StringIO.new( <<-DOC ),options) { "name": "attribute_3", "label": "New Label", "type": "string", "default_value": null, "is_system": false, "is_permanent": null, "value_is_hidden": false, "user_can_view": true, "user_can_edit": true, "hidden_value_domain_whitelist": null, "can": { "show": true, "index": true, "create": true, "show_value": true, "update": true, "destroy": true, "set_value": true } } DOC command.instance_variable_set(:@sdk, mock_sdk()) command.execute(output: output) expect(output.string).to eq <<-OUT Imported attribute attribute_3 3 OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/attribute/ls_spec.rb
spec/unit/attribute/ls_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/attribute/ls' RSpec.describe Gzr::Commands::Attribute::Ls do attrs = [ { :id=>1, :name=>"attribute_1", :label=>"Attribute 1", :type=>"string", :default_value=>nil, :is_system=>true, :is_permanent=>nil, :value_is_hidden=>false, :user_can_view=>true, :user_can_edit=>true, :hidden_value_domain_whitelist=>nil }.freeze, { :id=>2, :name=>"attribute_2", :label=>"Attribute 2", :type=>"number", :default_value=>5, :is_system=>false, :is_permanent=>nil, :value_is_hidden=>false, :user_can_view=>true, :user_can_edit=>true, :hidden_value_domain_whitelist=>nil }.freeze, { :id=>3, :name=>"attribute_3", :label=>"Attribute 3", :type=>"string", :default_value=>nil, :is_system=>false, :is_permanent=>nil, :value_is_hidden=>false, :user_can_view=>true, :user_can_edit=>false, :hidden_value_domain_whitelist=>nil }.freeze ] define_method :mock_sdk do |block_hash={}| mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:all_user_attributes) do |req| if block_hash && block_hash[:all_user_attributes] block_hash[:all_user_attributes].call() end attrs.map {|a| HashResponse.new(a)} end mock_sdk end it "executes `attribute ls` command successfully" do output = StringIO.new options = {:fields => 'id,name,label,type,default_value'} command = Gzr::Commands::Attribute::Ls.new(options) command.instance_variable_set(:@sdk, mock_sdk()) command.execute(output: output) expect(output.string).to eq <<-OUT +--+-----------+-----------+------+-------------+ |id|name |label |type |default_value| +--+-----------+-----------+------+-------------+ | 1|attribute_1|Attribute 1|string| | | 2|attribute_2|Attribute 2|number|5 | | 3|attribute_3|Attribute 3|string| | +--+-----------+-----------+------+-------------+ OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/attribute/create_spec.rb
spec/unit/attribute/create_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/attribute/create' require 'json' RSpec.describe Gzr::Commands::Attribute::Create do attrs = [ { :id => 1, :name => "attribute_1", :label => "Attribute 1", :type => "string", :default_value => nil, :is_system => true, :is_permanent => nil, :value_is_hidden => false, :user_can_view => true, :user_can_edit => true, :hidden_value_domain_whitelist => nil }.freeze, { :id => 2, :name => "attribute_2", :label => "Attribute 2", :type => "number", :default_value => 5, :is_system => false, :is_permanent => nil, :value_is_hidden => false, :user_can_view => true, :user_can_edit => true, :hidden_value_domain_whitelist => nil }.freeze, { :id => 3, :name => "attribute_3", :label => "Attribute 3", :type => "string", :default_value => nil, :is_system => false, :is_permanent => nil, :value_is_hidden => false, :user_can_view => true, :user_can_edit => false, :hidden_value_domain_whitelist => nil }.freeze ] operations = { :create_user_attribute => { :info => { :parameters => [ { :in => "body", :schema => { :$ref=>"#/definitions/UserAttribute" } } ] } }, :update_user_attribute => { :info => { :parameters => [ { "name": "user_attribute_id", "in": "path", "description": "Id of user attribute", "required": true, "type": "integer", "format": "int64" }, { :in => "body", :schema => { :$ref=>"#/definitions/UserAttribute" } } ] } } }.freeze swagger = JSON.parse(<<-SWAGGER, {:symbolize_names => true}).freeze { "definitions": { "UserAttribute": { "properties": { "id": { "type": "integer", "format": "int64", "readOnly": true, "description": "Unique Id", "x-looker-nullable": false }, "name": { "type": "string", "description": "Name of user attribute", "x-looker-nullable": true }, "label": { "type": "string", "description": "Human-friendly label for user attribute", "x-looker-nullable": true }, "type": { "type": "string", "description": "Type of user attribute", "x-looker-nullable": true }, "default_value": { "type": "string", "description": "Default value for when no value is set on the user", "x-looker-nullable": true }, "is_system": { "type": "boolean", "readOnly": true, "description": "Attribute is a system default", "x-looker-nullable": false }, "user_can_view": { "type": "boolean", "description": "Non-admin users can see the values of their attributes and use them in filters", "x-looker-nullable": false }, "user_can_edit": { "type": "boolean", "description": "Users can change the value of this attribute for themselves", "x-looker-nullable": false } }, "x-looker-status": "stable" } } } SWAGGER define_method :mock_sdk do |block_hash={}| mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:operations) { operations } mock_sdk.define_singleton_method(:swagger) { swagger } mock_sdk.define_singleton_method(:all_user_attributes) do |req| if block_hash && block_hash[:all_user_attributes] block_hash[:all_user_attributes].call(req) end attrs.map {|a| HashResponse.new(a)} end mock_sdk.define_singleton_method(:user_attribute) do |id,req| if block_hash && block_hash[:user_attribute] block_hash[:user_attribute].call(id,req) end found = attrs.select {|a| a[:id] == id.to_i } return HashResponse.new(found.first) if found && !found.empty? nil end mock_sdk.define_singleton_method(:create_user_attribute) do |req| if block_hash && block_hash[:create_user_attribute] block_hash[:create_user_attribute].call(id) end req[:id] = 4 HashResponse.new(req) end mock_sdk.define_singleton_method(:update_user_attribute) do |id,req| if block_hash && block_hash[:update_user_attribute] block_hash[:update_user_attribute].call(id,req) end found = attrs.select {|a| a[:id] == id.to_i } return HashResponse.new(found.first.merge(req)) if found && !found.empty? nil end mock_sdk end it "executes `attribute create` command successfully for a new attribute" do output = StringIO.new options = {:type => "string", :'is-hidden' => false, :'can-view' => true, :'can-edit' => true} command = Gzr::Commands::Attribute::Create.new("attribute_4", "Attribute 4",options) command.instance_variable_set(:@sdk, mock_sdk()) command.execute(output: output) expect(output.string).to eq <<-OUT Imported attribute attribute_4 4 OUT end it "executes `attribute create` command successfully with an existing attribute" do output = StringIO.new options = {:type => "string", :'is-hidden' => false, :'can-view' => true, :'can-edit' => true, :force => true} command = Gzr::Commands::Attribute::Create.new("attribute_3", "New Label",options) command.instance_variable_set(:@sdk, mock_sdk()) command.execute(output: output) expect(output.string).to eq <<-OUT Imported attribute attribute_3 3 OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/attribute/get_group_value_spec.rb
spec/unit/attribute/get_group_value_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/attribute/get_group_value' RSpec.describe Gzr::Commands::Attribute::GetGroupValue do groups = [ { :id=>1, :name=>"group_1" }.freeze, { :id=>2, :name=>"group_2" }.freeze, { :id=>3, :name=>"group_3" }.freeze ] attrs = [ { :id=>1, :name=>"attribute_1", :label=>"Attribute 1", :type=>"string", :default_value=>nil, :is_system=>true, :is_permanent=>nil, :value_is_hidden=>false, :user_can_view=>true, :user_can_edit=>true, :hidden_value_domain_whitelist=>nil }.freeze, { :id=>2, :name=>"attribute_2", :label=>"Attribute 2", :type=>"number", :default_value=>5, :is_system=>false, :is_permanent=>nil, :value_is_hidden=>false, :user_can_view=>true, :user_can_edit=>true, :hidden_value_domain_whitelist=>nil }.freeze, { :id=>3, :name=>"attribute_3", :label=>"Attribute 3", :type=>"string", :default_value=>nil, :is_system=>false, :is_permanent=>nil, :value_is_hidden=>false, :user_can_view=>true, :user_can_edit=>false, :hidden_value_domain_whitelist=>nil }.freeze ] define_method :mock_sdk do |block_hash={}| mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:group) do |id,req| if block_hash && block_hash[:group] block_hash[:group].call(id,req) end found = groups.select {|a| a[:id] == id.to_i } return HashResponse.new(found.first) if found && !found.empty? nil end mock_sdk.define_singleton_method(:search_groups) do |req| if block_hash && block_hash[:search_groups] block_hash[:search_groups].call(req) end found = groups.select {|a| a[:name] == req[:name] } return nil if found.nil? || found.empty? found.map{|a| HashResponse.new(a)} end mock_sdk.define_singleton_method(:all_user_attributes) do |req| if block_hash && block_hash[:all_user_attributes] block_hash[:all_user_attributes].call(req) end attrs.map {|a| HashResponse.new(a)} end mock_sdk.define_singleton_method(:user_attribute) do |id,req| if block_hash && block_hash[:user_attribute] block_hash[:user_attribute].call(id,req) end found = attrs.select {|a| a[:id] == id.to_i } return HashResponse.new(found.first) if found && !found.empty? nil end mock_sdk.define_singleton_method(:all_user_attribute_group_values) do |id,req| if block_hash && block_hash[:all_user_attribute_group_values] block_hash[:all_user_attribute_group_values].call(id,req) end found_attrs = attrs.select {|a| a[:id] == id.to_i } return nil if found_attrs.nil? || found_attrs.empty? values = [ [nil, nil, nil, nil], [nil, 'Test', nil, 'Test2'], [nil, nil, 'Test5', 'Test6'], [nil, 'Test9','Test8', 'Test7'] ] found_attrs.map do |a| groups.map do |g| { :group_id=>g[:id], :user_attribute_id=>a[:id], :value=>values[g[:id]][a[:id]] } end end.flatten.map {|r| HashResponse.new(r)} end mock_sdk end it "executes `attribute get_group_value` command successfully with ids" do output = StringIO.new options = {} command = Gzr::Commands::Attribute::GetGroupValue.new("1","3",options) command.instance_variable_set(:@sdk, mock_sdk()) command.execute(output: output) expect(output.string).to eq("Test2\n") end it "executes `attribute get_group_value` command successfully with names" do output = StringIO.new options = {} command = Gzr::Commands::Attribute::GetGroupValue.new("group_3","attribute_2",options) command.instance_variable_set(:@sdk, mock_sdk()) command.execute(output: output) expect(output.string).to eq("Test8\n") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/attribute/rm_spec.rb
spec/unit/attribute/rm_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/attribute/rm' RSpec.describe Gzr::Commands::Attribute::Rm do attrs = [ { :id=>1, :name=>"attribute_1", :label=>"Attribute 1", :type=>"string", :default_value=>nil, :is_system=>true, :is_permanent=>nil, :value_is_hidden=>false, :user_can_view=>true, :user_can_edit=>true, :hidden_value_domain_whitelist=>nil }.freeze, { :id=>2, :name=>"attribute_2", :label=>"Attribute 2", :type=>"number", :default_value=>5, :is_system=>false, :is_permanent=>nil, :value_is_hidden=>false, :user_can_view=>true, :user_can_edit=>true, :hidden_value_domain_whitelist=>nil }.freeze, { :id=>3, :name=>"attribute_3", :label=>"Attribute 3", :type=>"string", :default_value=>nil, :is_system=>false, :is_permanent=>nil, :value_is_hidden=>false, :user_can_view=>true, :user_can_edit=>false, :hidden_value_domain_whitelist=>nil }.freeze ] define_method :mock_sdk do |block_hash={}| mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:all_user_attributes) do |req| if block_hash && block_hash[:all_user_attributes] block_hash[:all_user_attributes].call(req) end attrs.map {|a| HashResponse.new(a)} end mock_sdk.define_singleton_method(:user_attribute) do |id,req| if block_hash && block_hash[:user_attribute] block_hash[:user_attribute].call(id,req) end found = attrs.select {|a| a[:id] == id.to_i } return HashResponse.new(found.first) if found && !found.empty? nil end mock_sdk.define_singleton_method(:delete_user_attribute) do |id| if block_hash && block_hash[:delete_user_attribute] block_hash[:delete_user_attribute].call(id) end found = attrs.select {|a| a[:id] == id.to_i } return nil if found && !found.empty? end mock_sdk end it "executes `attribute rm` command successfully with id" do output = StringIO.new options = {} command = Gzr::Commands::Attribute::Rm.new("3",options) command.instance_variable_set(:@sdk, mock_sdk()) command.execute(output: output) expect(output.string).to eq("Deleted attribute attribute_3 3\n") end it "executes `attribute rm` command successfully with name" do output = StringIO.new options = {} command = Gzr::Commands::Attribute::Rm.new("attribute_3",options) command.instance_variable_set(:@sdk, mock_sdk()) command.execute(output: output) expect(output.string).to eq("Deleted attribute attribute_3 3\n") end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/attribute/cat_spec.rb
spec/unit/attribute/cat_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/attribute/cat' RSpec.describe Gzr::Commands::Attribute::Cat do attrs = [ { :id=>1, :name=>"attribute_1", :label=>"Attribute 1", :type=>"string", :default_value=>nil, :is_system=>true, :is_permanent=>nil, :value_is_hidden=>false, :user_can_view=>true, :user_can_edit=>true, :hidden_value_domain_whitelist=>nil }.freeze, { :id=>2, :name=>"attribute_2", :label=>"Attribute 2", :type=>"number", :default_value=>5, :is_system=>false, :is_permanent=>nil, :value_is_hidden=>false, :user_can_view=>true, :user_can_edit=>true, :hidden_value_domain_whitelist=>nil }.freeze, { :id=>3, :name=>"attribute_3", :label=>"Attribute 3", :type=>"string", :default_value=>nil, :is_system=>false, :is_permanent=>nil, :value_is_hidden=>false, :user_can_view=>true, :user_can_edit=>false, :hidden_value_domain_whitelist=>nil }.freeze ] define_method :mock_sdk do |block_hash={}| mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:all_user_attributes) do |req| if block_hash && block_hash[:all_user_attributes] block_hash[:all_user_attributes].call(req) end attrs.map {|a| HashResponse.new(a)} end mock_sdk.define_singleton_method(:user_attribute) do |id,req| if block_hash && block_hash[:user_attribute] block_hash[:user_attribute].call(id,req) end found = attrs.select {|a| a[:id] == id.to_i } return HashResponse.new(found.first) if found && !found.empty? nil end mock_sdk end it "executes `attribute cat` command successfully with id" do output = StringIO.new options = {} command = Gzr::Commands::Attribute::Cat.new("3",options) command.instance_variable_set(:@sdk, mock_sdk()) command.execute(output: output) expect(output.string).to eq <<-OUT { "id": 3, "name": "attribute_3", "label": "Attribute 3", "type": "string", "default_value": null, "is_system": false, "is_permanent": null, "value_is_hidden": false, "user_can_view": true, "user_can_edit": false, "hidden_value_domain_whitelist": null } OUT end it "executes `attribute cat` command successfully with name" do output = StringIO.new options = {} command = Gzr::Commands::Attribute::Cat.new("attribute_3",options) command.instance_variable_set(:@sdk, mock_sdk()) command.execute(output: output) expect(output.string).to eq <<-OUT { "id": 3, "name": "attribute_3", "label": "Attribute 3", "type": "string", "default_value": null, "is_system": false, "is_permanent": null, "value_is_hidden": false, "user_can_view": true, "user_can_edit": false, "hidden_value_domain_whitelist": null } OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/spec/unit/permission/ls_spec.rb
spec/unit/permission/ls_spec.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require 'gzr/commands/permission/ls' RSpec.describe Gzr::Commands::Permission::Ls do it "executes `ls` command successfully" do require 'sawyer' response_doc = { :permission=>"sudo", :parent=>"see_users", :description=>"Enables sudo-ing" } mock_response = double(Sawyer::Resource, response_doc) allow(mock_response).to receive(:to_attrs).and_return(response_doc) mock_sdk = Object.new mock_sdk.define_singleton_method(:authenticated?) { true } mock_sdk.define_singleton_method(:logout) { } mock_sdk.define_singleton_method(:all_permissions) do return [mock_response] end output = StringIO.new options = {} command = Gzr::Commands::Permission::Ls.new(options) command.instance_variable_set(:@sdk, mock_sdk) command.execute(output: output) expect(output.string).to eq <<-OUT +----------+---------+----------------+ |permission|parent |description | +----------+---------+----------------+ |sudo |see_users|Enables sudo-ing| +----------+---------+----------------+ OUT end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr.rb
lib/gzr.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require "gzr/version" module Gzr end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/command.rb
lib/gzr/command.rb
# The MIT icense (MIT) # Copyright (c) 2023 Mike DeAngelo Google, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require 'forwardable' require 'tty-reader' require 'netrc' require 'looker-sdk' require 'faraday/multipart' require_relative 'modules/session' module Gzr class Command extend Forwardable include Gzr::Session def initialize @sdk = nil @access_token_stack = Array.new @options = Hash.new end def_delegators :command, :run # Execute this command # # @api public def execute(*) raise( NotImplementedError, "#{self.class}##{__method__} must be implemented" ) end def get_user_by_id(user_id, req=nil) begin @sdk.user(user_id, req).to_attrs rescue LookerSDK::NotFound => e nil rescue LookerSDK::Error => e say_error "Error querying get_user_by_id(#{user_id})" say_error e raise end end def get_auth() begin return @sdk.session()&.to_attrs rescue LookerSDK::Error => e say_error "Unable to run session()" say_error e end end def query(query_id) data = nil begin data = @sdk.query(query_id) rescue LookerSDK::Error => e say_error "Error querying query(#{query_id})" say_error e raise end data end def create_query(query) begin data = @sdk.create_query(query) if !(data.respond_to?(:id)) raise Gzr::CLI::Error, "create_query(#{JSON.pretty_generate(query)}) returned #{data.inspect}" end rescue LookerSDK::Error => e say_error "Error creating query(#{JSON.pretty_generate(query)})" say_error e raise end data end def merge_query(merge_result_id) data = nil begin data = @sdk.merge_query(merge_result_id) rescue NoMethodError => nme say_error "The api endpoint merge_query(#{merge_result_id}) is not implemented on this Looker instance" rescue LookerSDK::Error => e say_error "Error querying merge_query(#{merge_result_id})" say_error e raise end data end def create_merge_query(merge_query) begin data = @sdk.create_merge_query(merge_query) rescue NoMethodError => nme say_error "The api endpoint create_merge_query() is not implemented on this Looker instance" raise rescue LookerSDK::Error => e say_error "Error creating merge_query(#{JSON.pretty_generate(merge_query)})" say_error e raise end data end def run_inline_query(query) begin @sdk.run_inline_query("json",query).collect { |r| r.to_attrs } rescue LookerSDK::Error => e say_error "Error running inline_query(#{JSON.pretty_generate(query)})" say_error e raise end end def all_color_collections() data = nil begin data = @sdk.all_color_collections().collect { |o| o.to_attrs if o.respond_to?(:to_attrs) } rescue NoMethodError => nme say_warning "The api endpoint all_color_collections() is not implemented on this Looker instance" rescue LookerSDK::NotFound => nf say_warning "The current user can't query all color collections" rescue LookerSDK::Error => e say_error "Error querying all_color_collections()" say_error e raise end data end def default_color_collection() return @dcc if @dcc data = nil begin data = @sdk.default_color_collection().to_attrs @dcc = data rescue NoMethodError => nme say_warning "The api endpoint default_color_collection() is not implemented on this Looker instance" rescue LookerSDK::NotFound => nf say_warning "The current user can't query the default color collection" rescue LookerSDK::Error => e say_error "Error querying default_color_collection()" say_error e raise end data end def color_collection(collection_id) data = nil begin data = @sdk.color_collection(collection_id).to_attrs rescue NoMethodError => nme say_warning "The api endpoint color_collection(collection_id) is not implemented on this Looker instance" rescue LookerSDK::NotFound => nf say_warning "The color_collection(#{collection_id}) is not found" rescue LookerSDK::Error => e say_error "Error querying color_collection(#{collection_id})" say_error e raise end data end def find_vis_config_reference(obj, &block) if obj.respond_to?(:'has_key?') && obj.has_key?(:vis_config) yield (obj[:vis_config]) elsif obj.is_a? Enumerable obj.each { |o| find_vis_config_reference(o,&block) } end end def find_color_palette_reference(obj, default_colors=nil, &block) begin dcc = default_color_collection() if dcc.nil? say_warning "You do not have access to query color palettes so these won't be processed." return end @default_colors=color_palette_lookup!(dcc) #say_warning("Default colors #{JSON.pretty_generate @default_colors}") if @options[:debug] end unless @default_colors if obj.respond_to?(:'has_key?') && obj.has_key?(:collection_id) && obj.has_key?(:palette_id) yield(obj,@default_colors) elsif obj.is_a? Enumerable obj.each { |o| find_color_palette_reference(o,@default_colors,&block) } end end def color_palette_lookup!(obj) return nil unless obj.respond_to?(:'has_key?') #say_warning("performing color_palette_lookup! on #{JSON.pretty_generate obj}") if @options[:debug] palettes = [] palettes += obj[:categoricalPalettes] if obj[:categoricalPalettes] palettes += obj[:sequentialPalettes] if obj[:sequentialPalettes] palettes += obj[:divergingPalettes] if obj[:divergingPalettes] obj[:palettes]=palettes #say_warning("got palettes #{JSON.pretty_generate palettes}") if @options[:debug] obj end def rewrite_color_palette!(o,default_colors) cc = nil if o[:collection_id] == default_colors[:id] o[:collection_default] = true cc = default_colors else o[:collection_default] = false #say_ok("looking up color collection by id #{o[:collection_id]}") if @options[:debug] cc = color_palette_lookup!(color_collection(o[:collection_id])) end return unless cc #say_warning("got color collection #{JSON.pretty_generate cc}") if @options[:debug] o[:collection_label] = cc[:label] ps = cc[:palettes].select { |p| p[:id] == o[:palette_id] } if ps.length > 0 p = ps.first o[:palette_label] = p[:label] o[:palette_type] = p[:type] o[:palette_colors] = p[:colors] if p[:colors] o[:palette_stops] = p[:stops] if p[:stops] end end def update_color_palette!(o,default_colors,force_default=false) return unless o.has_key?(:collection_label) && o.has_key?(:palette_type) cc = default_colors if !(force_default && o[:collection_default]) # look up color collection by id #say_warning("attempting to match palette on id #{o[:collection_id]}") if @options[:debug] cc = color_palette_lookup!(color_collection(o[:collection_id])) if cc.nil? # find color collection by name #say_warning("no match on id, attempting to match palette on name #{o[:collection_label]}") if @options[:debug] ccs = all_color_collections()&.select { |cc| o[:collection_label] == cc[:label]} if ccs.nil? || ccs.length == 0 # no color collection found. Use default. say_warning "Color collection #{o[:collection_label]} not found. Using default." cc = default_colors else cc = color_palette_lookup!(ccs.first) end end end o[:collection_id] = cc[:id] # look up palette by id ps = cc[:palettes].select {|p| p[:id] == o[:palette_id]} if ps.length == 0 # find palette by type ps = cc[:palettes].select {|p| p[:type] == o[:palette_type]} if ps.length > 0 o[:palette_id] = ps.first[:id] else # no palette found say_warning "Color palette #{o[:palette_type]} not found." o.delete(:palette_id) end end end ## # This method accepts the name of an sdk operation, then finds the parameter for that # operation in the data structures from the swagger.json file. The parameter is a # json object. Some of the attributes of the json object are read-only, and some # are read-write. A few are write-only. The list of read-write and write-only attribute # names are returned as an array. That array can be used to take the json document that # describes an object and strip out the read-only values, creating a document that can # be used to create or update an object. # # The pattern typically looks like this... # # new_obj_hash = existing_obj_hash.select do |k,v| # keys_to_keep('create_new_obj').include? k # end def keys_to_keep(operation) @keys_to_keep_cache ||= {} @keys_to_keep_cache[operation] ||= keys_to_keep_internal(operation) end def keys_to_keep_internal(operation) o = @sdk.operations[operation] || @sdk.operations[operation.to_sym] begin say_error "Operation #{operation} not found" return [] end unless o parameters = o[:info][:parameters].select { |p| p[:in] == "body" && p[:schema] } say_warning "Expecting exactly one body parameter with a schema for operation #{operation}" unless parameters.length == 1 schema_ref = parameters[0][:schema][:$ref].split(/\//) key_list = @sdk.swagger[schema_ref[1].to_sym][schema_ref[2].to_sym][:properties].reject { |k,v| v[:readOnly] }.keys say_warning "key_list #{operation} -> #{key_list}" if @options[:debug] return key_list end ## # The tty-table gem is normally used to output tabular data. This method accepts a Table # object as used by the tty-table gem, and generates CSV output. It returns a string # with crlf encoding def render_csv(t) io = StringIO.new io.puts ( t.header.collect do |v| v ? "\"#{v.to_s.gsub(/"/, '""')}\"" : "" end.join(',') ) unless @options[:plain] t.each do |row| next if row === t.header io.puts ( row.collect do |v| v ? "\"#{v.to_s.gsub(/"/, '""')}\"" : "" end.join(',') ) end io.rewind io.gets(nil).encode(crlf_newline: true) end ## # This method accepts a string containing a list of fields. The fields can be nested # in a format like... # # 'a,b,c(d,e(f,g)),h' # # representing a structure like # # { # a: "val", # b: "val", # c: { # d: "val", # e: { # f: "val", # g: "val" # } # }, # h: "val" # } # # That string will get parsed and yield an array like # [ a, b, c.d, c.e.f, c.e.g, h ] # def field_names(opt_fields) fields = [] token_stack = [] last_token = false tokens = opt_fields.split /(\(|,|\))/ tokens << nil tokens.each do |t| if t.nil? then fields << (token_stack + [last_token]).join('.') if last_token elsif t.empty? then next elsif t == ',' then fields << (token_stack + [last_token]).join('.') if last_token elsif t == '(' then token_stack.push(last_token) elsif t == ')' then fields << (token_stack + [last_token]).join('.') if last_token token_stack.pop last_token = false else last_token = t end end fields end ## # This method will accept an array of field name expressions in a format like 'c.e.g' # and convert each into the value of g, or nil if any intermediate value is nil. def field_expressions_eval(expressions, data) expressions.map do |exp| nesting = exp.split('.') current = data while (nesting.length > 0) do field = nesting.shift if (current.kind_of?(Hash)) value = current.fetch(field.to_sym,nil) current = value else current = nil end end if current.kind_of? Array current = current.join("\n") end current end end ## # This method will accept two arrays, a and b, and create a third array # like [ [a[0],b[0]], [a[1],b[1]], [a[2],b[2]], ...]. # If either array is longer than the other, additional pairs # will be generated with the shorter array padded out with nil values. # # Any additional args will be added to each inner array. def pairs(a, b, *args) pair_array = Array.new([a.count,b.count].max) do |i| pair = [a.fetch(i,nil),b.fetch(i,nil)] pair += args if args pair end return pair_array unless block_given? pair_array.collect { |e| yield(e) } end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/version.rb
lib/gzr/version.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. module Gzr VERSION = '0.3.18'.freeze end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/cli.rb
lib/gzr/cli.rb
# The MIT License (MIT) # Copyright (c) 2023 Mike DeAngelo Google, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require 'thor' module Gzr # Handle the application command line parsing # and the dispatch to various command objects # # @api public class CLI < Thor def self.exit_on_failure? true end class_option :debug, type: :boolean, default: false, desc: 'Run in debug mode' class_option :host, type: :string, default: 'localhost', desc: 'Looker Host' class_option :port, type: :string, default: '19999', desc: 'Looker API Port' class_option :client_id, type: :string, desc: 'API Client Id' class_option :client_secret, type: :string, desc: 'API Client Secret' class_option :ssl, type: :boolean, default: true, desc: 'Use ssl to communicate with host' class_option :verify_ssl, type: :boolean, default: true, desc: 'Verify the SSL certificate of the host' class_option :timeout, type: :numeric, default: 60, desc: 'Seconds to wait for a response from the server' class_option :http_proxy, type: :string, desc: 'HTTP Proxy for connecting to Looker host' class_option :force, type: :boolean, default: false, desc: 'Overwrite objects on server' class_option :su, type: :string, desc: 'After connecting, change to user_id given' class_option :width, type: :numeric, default: nil, desc: 'Width of rendering for tables' class_option :token, type: :string, default: nil, desc: "Access token to use for authentication" class_option :token_file, type: :boolean, default: false, desc: "Use access token stored in file for authentication" # Error raised by this runner Error = Class.new(StandardError) desc 'version', 'gzr version' def version require_relative 'version' puts "v#{Gzr::VERSION}" end map %w(--version -v) => :version map space: :folder # Alias space command to folder # map permissions: :permission # Alias permissions command to permission require_relative 'commands/alert' register Gzr::Commands::Alert, 'alert', 'alert [SUBCOMMAND]', 'Command description...' require_relative 'commands/attribute' register Gzr::Commands::Attribute, 'attribute', 'attribute [SUBCOMMAND]', 'Command description...' require_relative 'commands/permission' register Gzr::Commands::Permission, 'permission', 'permission [SUBCOMMAND]', 'Command to retrieve available permission' require_relative 'commands/query' register Gzr::Commands::Query, 'query', 'query [SUBCOMMAND]', 'Commands to retrieve and run queries' require_relative 'commands/role' register Gzr::Commands::Role, 'role', 'role [SUBCOMMAND]', 'Commands pertaining to roles' require_relative 'commands/plan' register Gzr::Commands::Plan, 'plan', 'plan [SUBCOMMAND]', 'Commands pertaining to plans' require_relative 'commands/group' register Gzr::Commands::Group, 'group', 'group [SUBCOMMAND]', 'Commands pertaining to groups' require_relative 'commands/model' register Gzr::Commands::Model, 'model', 'model [SUBCOMMAND]', 'Commands pertaining to LookML Models' require_relative 'commands/connection' register Gzr::Commands::Connection, 'connection', 'connection [SUBCOMMAND]', 'Commands pertaining to database connections and dialects' require_relative 'commands/user' register Gzr::Commands::User, 'user', 'user [SUBCOMMAND]', 'Commands pertaining to users' require_relative 'commands/dashboard' register Gzr::Commands::Dashboard, 'dashboard', 'dashboard [SUBCOMMAND]', 'Commands pertaining to dashboards' require_relative 'commands/look' register Gzr::Commands::Look, 'look', 'look [SUBCOMMAND]', 'Commands pertaining to looks' require_relative 'commands/folder' register Gzr::Commands::Folder, 'folder', 'folder [SUBCOMMAND]', 'Commands pertaining to folders' require_relative 'commands/session' register Gzr::Commands::Session, 'session', 'session [SUBCOMMAND]', 'Commands pertaining to sessions' require_relative 'commands/project' register Gzr::Commands::Project, 'project', 'project [SUBCOMMAND]', 'Commands pertaining to projects' end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/permission.rb
lib/gzr/commands/permission.rb
# The MIT License (MIT) # Copyright (c) 2023 Mike DeAngelo Google, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require_relative 'subcommandbase' module Gzr module Commands class Permission < SubCommandBase require_relative 'permission/set' register Gzr::Commands::Permission::Set, 'set', 'set [SUBCOMMAND]', 'Commands pertaining to permission sets' namespace :permission desc 'ls', 'List all available permissions' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def ls(*) if options[:help] invoke :help, ['ls'] else require_relative 'permission/ls' Gzr::Commands::Permission::Ls.new(options).execute end end desc 'tree', 'List all available permissions in a tree' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def tree(*) if options[:help] invoke :help, ['tree'] else require_relative 'permission/tree' Gzr::Commands::Permission::Tree.new(options).execute end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/session.rb
lib/gzr/commands/session.rb
# The MIT License (MIT) # Copyright (c) 2023 Mike DeAngelo Google, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require 'thor' module Gzr module Commands class Session < Thor namespace :session desc 'login', 'Create a persistent session' method_option :text, type: :boolean, default: false, desc: 'output token to screen instead of file' def login(*) if options[:help] invoke :help, ['login'] else require_relative 'session/login' Gzr::Commands::Session::Login.new(options).execute end end desc 'logout', 'End a persistent session' def logout(*) if options[:help] invoke :help, ['logout'] else require_relative 'session/logout' Gzr::Commands::Session::Logout.new(options).execute end end desc 'get', 'Get data about current session' def get(*) if options[:help] invoke :help, ['get'] else require_relative 'session/get' Gzr::Commands::Session::Get.new(options).execute end end desc 'update WORKSPACE_ID', 'change the workspace_id of the current session' def update(workspace_id) if options[:help] invoke :help, ['update'] else require_relative 'session/update' Gzr::Commands::Session::Update.new(workspace_id,options).execute end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/project.rb
lib/gzr/commands/project.rb
# The MIT License (MIT) # Copyright (c) 2023 Mike DeAngelo Google, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require 'thor' module Gzr module Commands class Project < Thor namespace :project desc 'ls', 'List all projects' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, default: 'id,name,git_production_branch_name', desc: 'Fields to display' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def ls(*) if options[:help] invoke :help, ['ls'] else require_relative 'project/ls' Gzr::Commands::Project::Ls.new(options).execute end end desc 'cat PROJECT_ID', 'Output json information about a project to screen or file' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :dir, type: :string, desc: 'Directory to store output file' method_option :trim, type: :boolean, desc: 'Trim output to minimal set of fields for later import' def cat(project_id) if options[:help] invoke :help, ['cat'] else require_relative 'project/cat' Gzr::Commands::Project::Cat.new(project_id,options).execute end end desc 'import PROJECT_FILE', 'Import a project from a file containing json information' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def import(project_file) if options[:help] invoke :help, ['import'] else require_relative 'project/import' Gzr::Commands::Project::Import.new(project_file,options).execute end end desc 'update PROJECT_ID PROJECT_FILE', 'Update the given project from a file containing json information' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def update(project_id,project_file) if options[:help] invoke :help, ['update'] else require_relative 'project/update' Gzr::Commands::Project::Update.new(project_id,project_file,options).execute end end desc 'deploy_key PROJECT_ID', 'Generate a git deploy public key for the given project' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def deploy_key(project_id) if options[:help] invoke :help, ['deploy_key'] else require_relative 'project/deploy_key' Gzr::Commands::Project::DeployKey.new(project_id,options).execute end end desc 'branch PROJECT_ID', 'List the active branch or all branches of PROJECT_ID' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :all, type: :boolean, default: false, desc: 'List all branches, not just the active branch' method_option :fields, type: :string, default: 'name,error,message', desc: 'Fields to display' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def branch(project_id) if options[:help] invoke :help, ['branch'] else require_relative 'project/branch' Gzr::Commands::Project::Branch.new(project_id, options).execute end end desc 'deploy PROJECT_ID', 'Deploy the active branch of PROJECT_ID to production' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def deploy(project_id) if options[:help] invoke :help, ['deploy'] else require_relative 'project/deploy' Gzr::Commands::Project::Deploy.new(project_id, options).execute end end desc 'checkout PROJECT_ID NAME', 'Change the active branch of PROJECT_ID to NAME' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def checkout(project_id,name) if options[:help] invoke :help, ['checkout'] else require_relative 'project/checkout' Gzr::Commands::Project::Checkout.new(project_id, name, options).execute end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/group.rb
lib/gzr/commands/group.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require_relative 'subcommandbase' module Gzr module Commands class Group < SubCommandBase namespace :group desc 'member_users GROUP_ID', 'List the users that are members of the given group' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, default: 'id,email,last_name,first_name,personal_folder_id,home_folder_id', desc: 'Fields to display' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def member_users(group_id) if options[:help] invoke :help, ['member_users'] else require_relative 'group/member_users' Gzr::Commands::Group::MemberUsers.new(group_id,options).execute end end desc 'member_groups GROUP_ID', 'List the groups that are members of the given group' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, default: 'id,name,user_count,contains_current_user,externally_managed,external_group_id', desc: 'Fields to display' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def member_groups(group_id) if options[:help] invoke :help, ['member_groups'] else require_relative 'group/member_groups' Gzr::Commands::Group::MemberGroups.new(group_id,options).execute end end desc 'ls', 'List the groups that are defined on this server' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, default: 'id,name,user_count,contains_current_user,externally_managed,external_group_id', desc: 'Fields to display' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def ls(*) if options[:help] invoke :help, ['ls'] else require_relative 'group/ls' Gzr::Commands::Group::Ls.new(options).execute end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/dashboard.rb
lib/gzr/commands/dashboard.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require_relative 'subcommandbase' module Gzr module Commands class Dashboard < SubCommandBase namespace :dashboard desc 'mv DASHBOARD_ID TARGET_FOLDER_ID', 'Move a dashboard to the given folder' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :force, type: :boolean, desc: 'Overwrite a dashboard with the same name in the target folder' def mv(dashboard_id, target_folder_id) if options[:help] invoke :help, ['mv'] else require_relative 'dashboard/mv' Gzr::Commands::Dashboard::Mv.new(dashboard_id, target_folder_id, options).execute end end desc 'cat DASHBOARD_ID', 'Output the JSON representation of a dashboard to the screen or a file' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :dir, type: :string, desc: 'Directory to store output file' method_option :plans, type: :boolean, desc: 'Include scheduled plans' method_option :transform, type: :string, desc: 'Fully-qualified path to a JSON file describing the transformations to apply' method_option :simple_filename, type: :boolean, desc: 'Use simple filename for output (Dashboard_<id>.json)' method_option :trim, type: :boolean, desc: 'Trim output to minimal set of fields for later import' def cat(dashboard_id) if options[:help] invoke :help, ['cat'] else require_relative 'dashboard/cat' Gzr::Commands::Dashboard::Cat.new(dashboard_id, options).execute end end desc 'import FILE DEST_FOLDER_ID', 'Import a dashboard from a file' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :plain, type: :boolean, desc: 'Provide minimal response information' method_option :force, type: :boolean, desc: 'Overwrite a dashboard with the same name/slug in the target folder' def import(file,dest_folder_id) if options[:help] invoke :help, ['import'] else require_relative 'dashboard/import' Gzr::Commands::Dashboard::Import.new(file, dest_folder_id, options).execute end end desc 'rm DASHBOARD_ID', 'Remove or delete the given dashboard' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :soft, type: :boolean, desc: 'Soft delete the dashboard' method_option :restore, type: :boolean, desc: 'Restore a soft deleted dashboard' def rm(id) if options[:help] invoke :help, ['rm'] else require_relative 'dashboard/rm' Gzr::Commands::Dashboard::Rm.new(id, options).execute end end desc 'import_lookml DASHBOARD_ID TARGET_FOLDER_ID', 'Create a UDD from a lookml dashboard in the given folder' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :unlink, type: :boolean, desc: 'Unlink the new user defined dashboard from the LookML dashboard' method_option :force, type: :boolean, desc: 'Overwrite a dashboard with the same name in the target folder' method_option :sync, type: :boolean, desc: 'If linked dashboard already exists, sync it with LookML dashboard' def import_lookml(dashboard_id, target_folder_id) if options[:help] invoke :help, ['import_lookml'] else require_relative 'dashboard/import_lookml' Gzr::Commands::Dashboard::ImportLookml.new(dashboard_id, target_folder_id, options).execute end end desc 'sync_lookml DASHBOARD_ID', 'Sync any UDD from a lookml dashboard' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def sync_lookml(dashboard_id) if options[:help] invoke :help, ['sync_lookml'] else require_relative 'dashboard/sync_lookml' Gzr::Commands::Dashboard::SyncLookml.new(dashboard_id, options).execute end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/attribute.rb
lib/gzr/commands/attribute.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require 'thor' module Gzr module Commands class Attribute < Thor namespace :attribute desc 'set_group_value GROUP_ID|GROUP_NAME ATTR_ID|ATTR_NAME VALUE', 'Set a user attribute value for a group' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def set_group_value(group,attr,value) if options[:help] invoke :help, ['set_group_value'] else require_relative 'attribute/set_group_value' Gzr::Commands::Attribute::SetGroupValue.new(group,attr,value,options).execute end end desc 'get_group_value GROUP_ID|GROUP_NAME ATTR_ID|ATTR_NAME', 'Retrieve a user attribute value for a group' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def get_group_value(group,attr) if options[:help] invoke :help, ['get_group_value'] else require_relative 'attribute/get_group_value' Gzr::Commands::Attribute::GetGroupValue.new(group,attr,options).execute end end desc 'rm ATTR_ID|ATTR_NAME', 'Delete a user attribute' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :plain, type: :boolean, desc: 'Provide minimal response information' def rm(attr) if options[:help] invoke :help, ['rm'] else require_relative 'attribute/rm' Gzr::Commands::Attribute::Rm.new(attr,options).execute end end desc 'import FILE', 'Import a user attribute from a file' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :plain, type: :boolean, desc: 'Provide minimal response information' method_option :force, type: :boolean, desc: 'If the user attribute already exists, modify it' def import(file) if options[:help] invoke :help, ['import'] else require_relative 'attribute/import' Gzr::Commands::Attribute::Import.new(file,options).execute end end desc 'create ATTR_NAME [ATTR_LABEL] [OPTIONS]', 'Create or modify an attribute' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :plain, type: :boolean, desc: 'Provide minimal response information' method_option :force, type: :boolean, desc: 'If the user attribute already exists, modify it' method_option :type, type: :string, default: 'string', desc: '"string", "number", "datetime", "yesno", "zipcode"' method_option :'default-value', type: :string, desc: 'default value to be used if one not otherwise set' method_option :'is-hidden', type: :boolean, default: false, desc: 'can a non-admin user view the value' method_option :'can-view', type: :boolean, default: true, desc: 'can a non-admin user view the value' method_option :'can-edit', type: :boolean, default: true, desc: 'can a user change the value themself' method_option :'domain-allowlist', type: :string, desc: 'what domains can receive the value of a hidden attribute.' def create(attr_name, attr_label=nil) if options[:help] invoke :help, ['create'] else require_relative 'attribute/create' Gzr::Commands::Attribute::Create.new(attr_name, attr_label, options).execute end end desc 'cat ATTR_ID|ATTR_NAME', 'Output json information about an attribute to screen or file' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, desc: 'Fields to display' method_option :dir, type: :string, desc: 'Directory to store output file' def cat(attr) if options[:help] invoke :help, ['cat'] else require_relative 'attribute/cat' Gzr::Commands::Attribute::Cat.new(attr,options).execute end end desc 'ls', 'List all the defined user attributes' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, default: 'id,name,label,type,default_value', desc: 'Fields to display' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def ls(*) if options[:help] invoke :help, ['ls'] else require_relative 'attribute/ls' Gzr::Commands::Attribute::Ls.new(options).execute end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/query.rb
lib/gzr/commands/query.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require_relative 'subcommandbase' module Gzr module Commands class Query < SubCommandBase namespace :query desc 'runquery QUERY_DEF', 'Run query_id, query_slug, or json_query_desc' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :file, type: :string, desc: 'Filename for saved data' method_option :format, type: :string, default: 'json', desc: 'One of json,json_detail,csv,txt,html,md,xlsx,sql,png,jpg' def runquery(query_def) if options[:help] invoke :help, ['runquery'] else require_relative 'query/runquery' Gzr::Commands::Query::RunQuery.new(query_def,options).execute end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/plan.rb
lib/gzr/commands/plan.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require_relative 'subcommandbase' module Gzr module Commands class Plan < SubCommandBase namespace :plan desc 'failures', 'Report all plans that failed in their most recent run attempt' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def failures(*) if options[:help] invoke :help, ['failures'] else require_relative 'plan/failures' Gzr::Commands::Plan::Failures.new(options).execute end end desc 'runit PLAN_ID', 'Execute a saved plan immediately' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def runit(plan_id) if options[:help] invoke :help, ['runit'] else require_relative 'plan/run' Gzr::Commands::Plan::RunIt.new(plan_id,options).execute end end desc 'disable PLAN_ID', 'Disable the specified plan' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def disable(plan_id) if options[:help] invoke :help, ['disable'] else require_relative 'plan/disable' Gzr::Commands::Plan::Disable.new(plan_id,options).execute end end desc 'enable PLAN_ID', 'Enable the specified plan' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def enable(plan_id) if options[:help] invoke :help, ['enable'] else require_relative 'plan/enable' Gzr::Commands::Plan::Enable.new(plan_id,options).execute end end desc 'rm PLAN_ID', 'Delete a scheduled plan' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def rm(plan_id) if options[:help] invoke :help, ['rm'] else require_relative 'plan/rm' Gzr::Commands::Plan::Rm.new(plan_id, options).execute end end desc 'import PLAN_FILE OBJ_TYPE OBJ_ID', 'Import a plan from a file' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :plain, type: :boolean, desc: 'Provide minimal response information' method_option :enable, type: :boolean, desc: 'Enable the plan on import' method_option :disable, type: :boolean, desc: 'Disable the plan on import' def import(plan_file, obj_type, id ) if options[:help] invoke :help, ['import'] else require_relative 'plan/import' Gzr::Commands::Plan::Import.new(plan_file, obj_type, id, options).execute end end desc 'cat PLAN_ID', 'Output the JSON representation of a scheduled plan to the screen or a file' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :dir, type: :string, desc: 'Directory to get output file' def cat(plan_id) if options[:help] invoke :help, ['cat'] else require_relative 'plan/cat' Gzr::Commands::Plan::Cat.new(plan_id,options).execute end end desc 'ls', 'List the scheduled plans on a server' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, default: 'id,enabled,name,user(id,display_name),look_id,dashboard_id,lookml_dashboard_id,crontab', desc: 'Fields to display' method_option :disabled, type: :boolean, desc: 'Retrieve disable plans' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def ls(*) if options[:help] invoke :help, ['ls'] else require_relative 'plan/ls' Gzr::Commands::Plan::Ls.new(options).execute end end desc 'randomize [PLAN_ID]', 'Randomize the scheduled plans on a server' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :window, type: :numeric, default: 60, desc: 'Length of window' method_option :all, type: :boolean, desc: 'Randomize all plans regardless of owner' def randomize(plan_id = nil) if options[:help] invoke :help, ['randomize'] else require_relative 'plan/randomize' Gzr::Commands::Plan::Randomize.new(plan_id, options).execute end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/connection.rb
lib/gzr/commands/connection.rb
# The MIT License (MIT) # Copyright (c) 2023 Mike DeAngelo Google, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require_relative 'subcommandbase' module Gzr module Commands class Connection < SubCommandBase namespace :connection desc 'dialects', 'List all available dialects' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, default: 'name,label', desc: 'Fields to display' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def dialects(*) if options[:help] invoke :help, ['dialects'] else require_relative 'connection/dialects' Gzr::Commands::Connection::Dialects.new(options).execute end end desc 'ls', 'List all available connections' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, default: 'name,dialect(name),host,port,database,schema', desc: 'Fields to display' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def ls(*) if options[:help] invoke :help, ['ls'] else require_relative 'connection/ls' Gzr::Commands::Connection::Ls.new(options).execute end end desc 'cat CONNECTION_NAME', 'Output the JSON representation of a connection to the screen or a file' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :dir, type: :string, desc: 'Directory to store output file' method_option :simple_filename, type: :boolean, desc: 'Use simple filename for output (Connection_<id>.json)' method_option :trim, type: :boolean, desc: 'Trim output to minimal set of fields for later import' def cat(connection_name) if options[:help] invoke :help, ['cat'] else require_relative 'connection/cat' Gzr::Commands::Connection::Cat.new(connection_name, options).execute end end desc 'rm CONNECTION_NAME', 'Delete a connection' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def rm(connection_name) if options[:help] invoke :help, ['rm'] else require_relative 'connection/rm' Gzr::Commands::Connection::Rm.new(connection_name, options).execute end end desc 'import FILE', 'Import a connection from a file' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :force, type: :boolean, desc: 'Overwrite an existing connection' method_option :prompt, type: :boolean, desc: 'Prompt for the password' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' def import(file) if options[:help] invoke :help, ['import'] else require_relative 'connection/import' Gzr::Commands::Connection::Import.new(file, options).execute end end desc 'test CONNECTION_NAME', 'Test the given connection' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, default: 'name,status,message', desc: 'Fields to display' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def test(connection_name) if options[:help] invoke :help, ['test'] else require_relative 'connection/test' Gzr::Commands::Connection::Test.new(connection_name,options).execute end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/subcommandbase.rb
lib/gzr/commands/subcommandbase.rb
# The MIT License (MIT) # Copyright (c) 2023 Mike DeAngelo Google, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require 'thor' module Gzr module Commands class SubCommandBase < Thor # Workaround so that help displays the right name # base on this link # https://github.com/erikhuda/thor/issues/261#issuecomment-69327685 def self.banner(command, namespace = nil, subcommand = false) "#{basename} #{subcommand_prefix} #{command.usage}" end def self.subcommand_prefix self.namespace end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/folder.rb
lib/gzr/commands/folder.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require_relative 'subcommandbase' module Gzr module Commands class Folder < SubCommandBase namespace :folder desc 'create NAME PARENT_FOLDER', 'Command description...' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :plain, type: :boolean, desc: 'Provide minimal response information' def create(name, parent_folder) if options[:help] invoke :help, ['create'] else require_relative 'folder/create' Gzr::Commands::Folder::Create.new(name, parent_folder, options).execute end end desc 'top', 'Retrieve the top level (or root) folders' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, default: 'id,name,is_shared_root,is_users_root,is_embed_shared_root,is_embed_users_root', desc: 'Fields to display' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def top(*) if options[:help] invoke :help, ['top'] else require_relative 'folder/top' Gzr::Commands::Folder::Top.new(options).execute end end desc 'export FOLDER_ID', 'Export a folder, including all child looks, dashboards, and folders.' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :plans, type: :boolean, desc: 'Include scheduled plans' method_option :trim, type: :boolean, desc: 'Trim output to minimal set of fields for later import' method_option :dir, type: :string, default: '.', desc: 'Directory to store output tree' method_option :tar, type: :string, desc: 'Tar file to store output' method_option :tgz, type: :string, desc: 'TarGZ file to store output' method_option :zip, type: :string, desc: 'Zip file to store output' def export(starting_folder) if options[:help] invoke :help, ['export'] else require_relative 'folder/export' Gzr::Commands::Folder::Export.new(starting_folder,options).execute end end desc 'tree STARTING_FOLDER', 'Display the dashboards, looks, and subfolders of a folder in a tree format' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def tree(starting_folder) if options[:help] invoke :help, ['tree'] else require_relative 'folder/tree' Gzr::Commands::Folder::Tree.new(starting_folder,options).execute end end desc 'cat FOLDER_ID', 'Output the JSON representation of a folder to the screen or a file' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :dir, type: :string, desc: 'Directory to get output file' def cat(folder_id) if options[:help] invoke :help, ['cat'] else require_relative 'folder/cat' Gzr::Commands::Folder::Cat.new(folder_id,options).execute end end desc 'ls FILTER_SPEC', 'list the contents of a folder given by folder name, folder_id, ~ for the current user\'s default folder, or ~name / ~number for the home folder of a user' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, default: 'parent_id,id,name,looks(id,title),dashboards(id,title)', desc: 'Fields to display' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def ls(filter_spec=nil) if options[:help] invoke :help, ['ls'] else require_relative 'folder/ls' Gzr::Commands::Folder::Ls.new(filter_spec,options).execute end end desc 'rm FOLDER_ID', 'Delete a folder. The folder must be empty or the --force flag specified to deleted subfolders, dashboards, and looks.' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def rm(folder_id) if options[:help] invoke :help, ['rm'] else require_relative 'folder/rm' Gzr::Commands::Folder::Rm.new(folder_id,options).execute end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/role.rb
lib/gzr/commands/role.rb
# The MIT License (MIT) # Copyright (c) 2023 Mike DeAngelo Google, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require 'thor' module Gzr module Commands class Role < Thor namespace :role desc 'group_rm ROLE_ID GROUP_ID GROUP_ID GROUP_ID ...', 'Remove indicated groups from role' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def group_rm(role_id, *groups) if options[:help] invoke :help, ['group_rm'] else require_relative 'role/group_rm' Gzr::Commands::Role::GroupRm.new(role_id, groups, options).execute end end desc 'user_rm ROLE_ID USER_ID USER_ID USER_ID ...', 'Remove indicated users from role' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def user_rm(role_id,*users) if options[:help] invoke :help, ['user_rm'] else require_relative 'role/user_rm' Gzr::Commands::Role::UserRm.new(role_id,users,options).execute end end desc 'group_add ROLE_ID GROUP_ID GROUP_ID GROUP_ID ...', 'Add indicated groups to role' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def group_add(role_id,*groups) if options[:help] invoke :help, ['group_add'] else require_relative 'role/group_add' Gzr::Commands::Role::GroupAdd.new(role_id, groups, options).execute end end desc 'user_add ROLE_ID USER_ID USER_ID USER_ID ...', 'Add indicated users to role' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def user_add(role_id,*users) if options[:help] invoke :help, ['user_add'] else require_relative 'role/user_add' Gzr::Commands::Role::UserAdd.new(role_id,users,options).execute end end desc 'group_ls ROLE_ID', 'List the groups assigned to a role' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, default: 'id,name,external_group_id', desc: 'Fields to display' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def group_ls(role_id) if options[:help] invoke :help, ['group_ls'] else require_relative 'role/group_ls' Gzr::Commands::Role::GroupLs.new(role_id,options).execute end end desc 'user_ls ROLE_ID', 'List the users assigned to a role' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, default: 'id,first_name,last_name,email', desc: 'Fields to display' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' method_option :all_users, type: :boolean, default: false, desc: 'Show users with this role through a group membership' def user_ls(role_id) if options[:help] invoke :help, ['user_ls'] else require_relative 'role/user_ls' Gzr::Commands::Role::UserLs.new(role_id,options).execute end end desc 'rm ROLE_ID', 'Delete a role' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def rm(role_id) if options[:help] invoke :help, ['rm'] else require_relative 'role/rm' Gzr::Commands::Role::Rm.new(role_id,options).execute end end desc 'cat ROLE_ID', 'Output the JSON representation of a role to screen/file' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :dir, type: :string, desc: 'Directory to get output file' method_option :trim, type: :boolean, desc: 'Trim output to minimal set of fields for later import' def cat(role_id) if options[:help] invoke :help, ['cat'] else require_relative 'role/cat' Gzr::Commands::Role::Cat.new(role_id,options).execute end end desc 'ls', 'Display all roles' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, default: 'id,name,permission_set(id,name,permissions),model_set(id,name,models)', desc: 'Fields to display' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def ls(*) if options[:help] invoke :help, ['ls'] else require_relative 'role/ls' Gzr::Commands::Role::Ls.new(options).execute end end desc 'create ROLE_NAME PERMISSION_SET_ID MODEL_SET_ID', "Create new role with the given permission and model sets" method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' def create(name, pset, mset) if options[:help] invoke :help, ['create'] else require_relative 'role/create' Gzr::Commands::Role::Create.new(name, pset, mset, options).execute end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/look.rb
lib/gzr/commands/look.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require_relative 'subcommandbase' module Gzr module Commands class Look < SubCommandBase namespace :look desc 'mv LOOK_ID TARGET_FOLDER_ID', 'Move a look to the given folder' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :force, type: :boolean, desc: 'Overwrite a look with the same name in the target folder' def mv(look_id, target_folder_id) if options[:help] invoke :help, ['mv'] else require_relative 'look/mv' Gzr::Commands::Look::Mv.new(look_id, target_folder_id, options).execute end end desc 'rm LOOK_ID', 'Delete look given by LOOK_ID' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :soft, type: :boolean, desc: 'Soft delete the look' method_option :restore, type: :boolean, desc: 'Restore a soft deleted look' def rm(look_id) if options[:help] invoke :help, ['rm'] else require_relative 'look/rm' Gzr::Commands::Look::Rm.new(look_id, options).execute end end desc 'import FILE DEST_FOLDER_ID', 'Import a look from a file' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :plain, type: :boolean, desc: 'Provide minimal response information' method_option :force, type: :boolean, desc: 'Overwrite a look with the same name/slug in the target folder' def import(file,dest_folder_id) if options[:help] invoke :help, ['import'] else require_relative 'look/import' Gzr::Commands::Look::Import.new(file, dest_folder_id, options).execute end end desc 'cat LOOK_ID', 'Output the JSON representation of a look to the screen or a file' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :dir, type: :string, desc: 'Directory to store output file' method_option :plans, type: :boolean, desc: 'Include scheduled plans' method_option :simple_filename, type: :boolean, desc: 'Use simple filename for output (Look_<id>.json)' method_option :trim, type: :boolean, desc: 'Trim output to minimal set of fields for later import' def cat(look_id) if options[:help] invoke :help, ['cat'] else require_relative 'look/cat' Gzr::Commands::Look::Cat.new(look_id, options).execute end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/model.rb
lib/gzr/commands/model.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require_relative 'subcommandbase' module Gzr module Commands class Model < SubCommandBase require_relative 'model/set' register Gzr::Commands::Model::Set, 'set', 'set [SUBCOMMAND]', 'Commands pertaining to model sets' namespace :model desc 'ls', 'List the models in this server.' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, default: 'name,label,project_name', desc: 'Fields to display' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def ls(*) if options[:help] invoke :help, ['ls'] else require_relative 'model/ls' Gzr::Commands::Model::Ls.new(options).execute end end desc 'cat MODEL_ID', 'Output json information about a model to screen or file' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :dir, type: :string, desc: 'Directory to store output file' method_option :trim, type: :boolean, desc: 'Trim output to minimal set of fields for later import' def cat(model_id) if options[:help] invoke :help, ['cat'] else require_relative 'model/cat' Gzr::Commands::Model::Cat.new(model_id,options).execute end end desc 'import MODEL_FILE', 'Import a model configuration from a file containing json information' method_option :force, type: :boolean, desc: 'Overwrite an existing connection' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def import(model_file) if options[:help] invoke :help, ['import'] else require_relative 'model/import' Gzr::Commands::Model::Import.new(model_file,options).execute end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/alert.rb
lib/gzr/commands/alert.rb
# The MIT License (MIT) # Copyright (c) 2023 Mike DeAngelo Google, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require 'thor' module Gzr module Commands class Alert < Thor namespace :alert desc 'ls', 'list alerts' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, default: 'id,field(title,name),comparison_type,threshold,cron,custom_title,dashboard_element_id,description', desc: 'Fields to display' method_option :disabled, type: :boolean, default: nil, desc: 'return disabled alerts' method_option :all, type: :boolean, default: nil, desc: 'return alerts from all users (must be admin)' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def ls(*) if options[:help] invoke :help, ['ls'] else require_relative 'alert/ls' Gzr::Commands::Alert::Ls.new(options).execute end end desc 'randomize [ALERT_ID]', 'Randomize the scheduled alerts on a server' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :window, type: :numeric, default: 60, desc: 'Length of window' method_option :all, type: :boolean, desc: 'Randomize all alerts regardless of owner' def randomize(alert_id=nil) if options[:help] invoke :help, ['randomize'] else require_relative 'alert/randomize' Gzr::Commands::Alert::Randomize.new(alert_id,options).execute end end desc 'cat ALERT_ID', 'Output json information about an alert to screen or file' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :dir, type: :string, desc: 'Directory to store output file' def cat(alert_id) if options[:help] invoke :help, ['cat'] else require_relative 'alert/cat' Gzr::Commands::Alert::Cat.new(alert_id,options).execute end end desc 'follow ALERT_ID', 'Start following the alert given by ALERT_ID' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def follow_alert(alert_id) if options[:help] invoke :help, ['follow'] else require_relative 'alert/follow' Gzr::Commands::Alert::Follow.new(alert_id,options).execute end end desc 'unfollow ALERT_ID', 'Stop following the alert given by ALERT_ID' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def unfollow_alert(alert_id) if options[:help] invoke :help, ['unfollow'] else require_relative 'alert/unfollow' Gzr::Commands::Alert::Unfollow.new(alert_id,options).execute end end desc 'enable ALERT_ID', 'Enable the alert given by ALERT_ID' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def enable(alert_id) if options[:help] invoke :help, ['enable'] else require_relative 'alert/enable' Gzr::Commands::Alert::Enable.new(alert_id,options).execute end end desc 'disable ALERT_ID REASON', 'Disable the alert given by ALERT_ID' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def disable(alert_id,reason) if options[:help] invoke :help, ['disable'] else require_relative 'alert/disable' Gzr::Commands::Alert::Disable.new(alert_id,reason,options).execute end end desc 'threshold ALERT_ID THRESHOLD', 'Change the threshold of the alert given by ALERT_ID' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def threshold(alert_id,threshold) if options[:help] invoke :help, ['threshold'] else require_relative 'alert/threshold' Gzr::Commands::Alert::Threshold.new(alert_id,threshold,options).execute end end desc 'rm ALERT_ID', 'Delete the alert given by ALERT_ID' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def rm(alert_id) if options[:help] invoke :help, ['delete'] else require_relative 'alert/delete' Gzr::Commands::Alert::Delete.new(alert_id,options).execute end end desc 'chown ALERT_ID OWNER_ID', 'Change the owner of the alert given by ALERT_ID to OWNER_ID' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def chown(alert_id, owner_id) if options[:help] invoke :help, ['chown'] else require_relative 'alert/chown' Gzr::Commands::Alert::Chown.new(alert_id,owner_id,options).execute end end desc 'notifications', 'Get notifications' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def notifications(*) if options[:help] invoke :help, ['notifications'] else require_relative 'alert/notifications' Gzr::Commands::Alert::Notifications.new(options).execute end end desc 'read NOTIFICATION_ID', 'Read notification id' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def read(notification_id) if options[:help] invoke :help, ['read'] else require_relative 'alert/read' Gzr::Commands::Alert::Read.new(notification_id,options).execute end end desc 'import FILE [DASHBOARD_ELEMENT_ID]', 'Import an alert from a file' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :plain, type: :boolean, desc: 'Provide minimal response information' def import(file,dashboard_element_id=nil) if options[:help] invoke :help, ['import'] else require_relative 'alert/import' Gzr::Commands::Alert::Import.new(file, dashboard_element_id, options).execute end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/user.rb
lib/gzr/commands/user.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require_relative 'subcommandbase' module Gzr module Commands class User < SubCommandBase namespace :user desc 'enable USER_ID', 'Enable the user given by user_id' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def enable(user_id) if options[:help] invoke :help, ['enable'] else require_relative 'user/enable' Gzr::Commands::User::Enable.new(user_id,options).execute end end desc 'disable USER_ID', 'Disable the user given by user_id' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def disable(user_id) if options[:help] invoke :help, ['disable'] else require_relative 'user/disable' Gzr::Commands::User::Disable.new(user_id,options).execute end end desc 'delete USER_ID', 'Delete the user given by user_id' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def delete(user_id) if options[:help] invoke :help, ['delete'] else require_relative 'user/delete' Gzr::Commands::User::Delete.new(user_id,options).execute end end desc 'cat USER_ID', 'Output json information about a user to screen or file' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, desc: 'Fields to display' method_option :dir, type: :string, desc: 'Directory to store output file' method_option :trim, type: :boolean, desc: 'Trim output to minimal set of fields for later import' def cat(user_id) if options[:help] invoke :help, ['cat'] else require_relative 'user/cat' Gzr::Commands::User::Cat.new(user_id,options).execute end end desc 'me', 'Show information for the current user' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, default: 'id,email,last_name,first_name,personal_folder_id,home_folder_id', desc: 'Fields to display' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def me(*) if options[:help] invoke :help, ['me'] else require_relative 'user/me' Gzr::Commands::User::Me.new(options).execute end end desc 'ls', 'list all users' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, default: 'id,email,last_name,first_name,personal_folder_id,home_folder_id', desc: 'Fields to display' method_option :"last-login", type: :boolean, default: false, desc: 'Include the time of the most recent login' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def ls(*) if options[:help] invoke :help, ['ls'] else require_relative 'user/ls' Gzr::Commands::User::Ls.new(options).execute end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/query/runquery.rb
lib/gzr/commands/query/runquery.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require_relative '../../command' require 'json' module Gzr module Commands class Query class RunQuery < Gzr::Command def initialize(query_def,options) super() @query_def = query_def @options = options end def execute(input: $stdin, output: $stdout) unless @query_def raise Gzr::CLI::Error, "No query specified. A query id, query slug, or a query in json formation must be specified." end case @options[:format] when 'png','jpg','xlsx' raise Gzr::CLI::Error, "Output file must be specified with '--file=filename' when using '--format=#{@options[:format]}" unless @options[:file] when 'json', 'json_detail', 'csv', 'txt', 'html', 'md', 'sql' # these formats can be output to stdout else raise Gzr::CLI::Error, "'--format=#{@options[:format]}' not understood. The format must be one of json,json_detail,csv,txt,html,md,xlsx,sql,png,jpg" end case @query_def when /^[0-9]+$/ query_id = @query_def.to_i when /^[A-Za-z0-9]+$/ query_slug = @query_def else begin query_hash = JSON.parse(@query_def,{:symbolize_names => true}) rescue JSON::ParserError => e raise Gzr::CLI::Error, "The query specification is not a valid id, slug, or json document" end end f = File.open(@options[:file], "w") if @options[:file] with_session do if query_id || query_slug then begin @sdk.query(query_id) rescue LookerSDK::NotFound => e raise Gzr::CLI::Error, "Query with the id #{query_id} not found" end if query_id begin query_id = @sdk.query_for_slug(query_slug, { :fields => 'id' }).id.to_i rescue LookerSDK::NotFound => e raise Gzr::CLI::Error, "Query with the slug #{query_slug} not found" end if query_slug begin @sdk.run_query(query_id,@options[:format]) { |data,progress| (f || output).write(data) } rescue LookerSDK::Error => e say_error "Error in run_query(#{query_id},#{@options[:format]})})" say_error e raise end else begin @sdk.run_inline_query(@options[:format],query_hash) { |data,progress| (f || output).write(data) } rescue LookerSDK::Error => e say_error "Error in run_inline_query(#{@options[:format]},#{JSON.pretty_generate(query_hash)})" say_error e raise end end end ensure f.close if f end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/user/me.rb
lib/gzr/commands/user/me.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require_relative '../../command' require_relative '../../modules/user' require 'tty-table' module Gzr module Commands class User class Me < Gzr::Command include Gzr::User def initialize(options) super() @options = options end def execute(input: $stdin, output: $stdout) say_warning(@options) if @options[:debug] with_session do data = query_me(@options[:fields]) table_hash = Hash.new fields = field_names(@options[:fields]) table_hash[:header] = fields unless @options[:plain] table_hash[:rows] = [data].map do |row| field_expressions_eval(fields,row) end table = TTY::Table.new(table_hash) if data alignments = fields.collect do |k| (k =~ /id$/) ? :right : :left end begin if @options[:csv] then output.puts render_csv(table) else output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width) end end if table end end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/user/enable.rb
lib/gzr/commands/user/enable.rb
# The MIT License (MIT) # Copyright (c) 2023 Mike DeAngelo Google, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require_relative '../../command' require_relative '../../modules/user' module Gzr module Commands class User class Enable < Gzr::Command include Gzr::User def initialize(user_id,options) super() @user_id = user_id @options = options end def execute(input: $stdin, output: $stdout) say_warning(@options) if @options[:debug] with_session do data = update_user(@user_id, { :is_disabled=>false }) say_error "user #{@user_id} not found" unless data end end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/user/disable.rb
lib/gzr/commands/user/disable.rb
# The MIT License (MIT) # Copyright (c) 2023 Mike DeAngelo Google, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require_relative '../../command' require_relative '../../modules/user' module Gzr module Commands class User class Disable < Gzr::Command include Gzr::User def initialize(user_id,options) super() @user_id = user_id @options = options end def execute(input: $stdin, output: $stdout) say_warning(@options) if @options[:debug] with_session do data = update_user(@user_id, { :is_disabled=>true }) say_error "user #{@user_id} not found" unless data end end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/user/delete.rb
lib/gzr/commands/user/delete.rb
# The MIT License (MIT) # Copyright (c) 2023 Mike DeAngelo Google, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require_relative '../../command' require_relative '../../modules/user' module Gzr module Commands class User class Delete < Gzr::Command include Gzr::User def initialize(user_id,options) super() @user_id = user_id @options = options end def execute(input: $stdin, output: $stdout) say_warning(@options) if @options[:debug] with_session do data = delete_user(@user_id) say_error "user #{@user_id} not found" unless data end end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/user/ls.rb
lib/gzr/commands/user/ls.rb
# The MIT License (MIT) # Copyright (c) 2023 Mike DeAngelo Google, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require_relative '../../command' require_relative '../../modules/user' require 'tty-table' module Gzr module Commands class User class Ls < Gzr::Command include Gzr::User def initialize(options) super() @options = options end def execute(input: $stdin, output: $stdout) say_warning(@options) if @options[:debug] credentials = [ 'credentials_email', 'credentials_embed', 'credentials_google', 'credentials_ldap', 'credentials_looker_openid', 'credentials_oidc', 'credentials_saml', 'credentials_totp' ] with_session do f = @options[:fields] f = f + ',' + credentials.join(',') if @options[:"last-login"] data = query_all_users(f, "id") begin say_ok "No users found" return nil end unless data && data.length > 0 table_hash = Hash.new fields = field_names(@options[:fields]) fields.unshift 'last_login' if @options[:"last-login"] table_hash[:header] = fields unless @options[:plain] table_hash[:rows] = data.map do |row| new_row = field_expressions_eval(fields,row) if @options[:"last-login"] new_row.shift new_row.unshift (credentials.map do |c| obj = row.fetch(c.to_sym) if obj.kind_of?(Array) obj.collect { |e| e.fetch(:logged_in_at,nil)&.to_s } else obj&.fetch(:logged_in_at,nil)&.to_s end end.flatten.compact.max) end new_row end table = TTY::Table.new(table_hash) alignments = fields.collect do |k| (k =~ /id$/) ? :right : :left end begin if @options[:csv] then output.puts render_csv(table) else output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width) end end if table end end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/user/cat.rb
lib/gzr/commands/user/cat.rb
# The MIT License (MIT) # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require_relative '../../command' require_relative '../../modules/user' require_relative '../../modules/filehelper' module Gzr module Commands class User class Cat < Gzr::Command include Gzr::User include Gzr::FileHelper def initialize(user_id,options) super() @user_id = user_id @options = options end def execute(input: $stdin, output: $stdout) say_warning("options: #{@options.inspect}") if @options[:debug] with_session do data = query_user(@user_id,@options[:fields]) data = trim_user(data) if @options[:trim] write_file(@options[:dir] ? "User_#{data[:id]}_#{data[:first_name]}_#{data[:last_name]}.json" : nil, @options[:dir],nil, output) do |f| f.puts JSON.pretty_generate(data) end if data say_error "user #{@user_id} not found" unless data end end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/model/set.rb
lib/gzr/commands/model/set.rb
# The MIT License (MIT) # Copyright (c) 2023 Mike DeAngelo Google, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require_relative '../subcommandbase' module Gzr module Commands class Model class Set < SubCommandBase namespace :'model set' desc 'ls', 'List the model sets in this server.' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :fields, type: :string, default: 'id,name,models', desc: 'Fields to display' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' method_option :csv, type: :boolean, default: false, desc: 'output in csv format per RFC4180' def ls(*) if options[:help] invoke :help, ['ls'] else require_relative 'set/ls' Gzr::Commands::Model::Set::Ls.new(options).execute end end desc 'cat MODEL_SET_ID', 'Output json information about a model set to screen or file' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :dir, type: :string, desc: 'Directory to store output file' method_option :trim, type: :boolean, desc: 'Trim output to minimal set of fields for later import' def cat(model_set_id) if options[:help] invoke :help, ['cat'] else require_relative 'set/cat' Gzr::Commands::Model::Set::Cat.new(model_set_id,options).execute end end desc 'import FILE', 'Import a model set from a file' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' method_option :force, type: :boolean, desc: 'Overwrite an existing model set' method_option :plain, type: :boolean, default: false, desc: 'print without any extra formatting' def import(file) if options[:help] invoke :help, ['import'] else require_relative 'set/import' Gzr::Commands::Model::Set::Import.new(file, options).execute end end desc 'rm MODEL_SET_ID', 'Delete the model_set given by MODEL_SET_ID' method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information' def rm(model_set_id) if options[:help] invoke :help, ['delete'] else require_relative 'set/rm' Gzr::Commands::Model::Set::Delete.new(model_set_id,options).execute end end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false
looker-open-source/gzr
https://github.com/looker-open-source/gzr/blob/329fd27a33941ecabc87192a5460efdf34352806/lib/gzr/commands/model/ls.rb
lib/gzr/commands/model/ls.rb
# The MIT License (MIT) # Copyright (c) 2023 Mike DeAngelo Google, Inc. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # frozen_string_literal: true require_relative '../../command' require_relative '../../modules/model' require 'tty-table' module Gzr module Commands class Model class Ls < Gzr::Command include Gzr::Model def initialize(options) super() @options = options end def execute(input: $stdin, output: $stdout) say_warning(@options) if @options[:debug] with_session do data = query_all_lookml_models(@options[:fields], @options[:debug]) begin say_ok "No users found" return nil end unless data && data.length > 0 table_hash = Hash.new fields = field_names(@options[:fields]) table_hash[:header] = fields unless @options[:plain] table_hash[:rows] = data.map do |row| field_expressions_eval(fields,row) end table = TTY::Table.new(table_hash) alignments = fields.collect do |k| (k =~ /id$/) ? :right : :left end begin if @options[:csv] then output.puts render_csv(table) else output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width) end end if table end end end end end end
ruby
MIT
329fd27a33941ecabc87192a5460efdf34352806
2026-01-04T17:49:18.520281Z
false