<commit_before>require 'fog/core/collection'
require 'fog/google/models/compute/server'

module Fog
  module Compute
    class Google

      class Servers < Fog::Collection

        model Fog::Compute::Google::Server

        def all(zone=nil)
          if zone.nil?
            data = []
            service.list_zones.body['items'].each do |zone|
              data += service.list_servers(zone['name']).body["items"] || []
            end
          else
            data = service.list_servers(zone).body["items"] || []
          end
          load(data)
        end

        def get(identity, zone=nil)
          data = nil
          if zone.nil?
            service.list_zones.body['items'].each do |zone|
              response = service.get_server(identity, zone['name'])
              data = response.body
              break if response.status == 200
            end
          else
            data = service.get_server(identity, zone).body
          end

          if data["code"] != 200
            nil
          else
            new(data)
          end
        rescue Excon::Errors::NotFound
          nil
        end

        def bootstrap(new_attributes = {})
          defaults = {
            :name => "fog-#{Time.now.to_i}",
            :image_name => "debian-7-wheezy-v20130522",
            :machine_type => "n1-standard-1",
            :zone_name => "us-central1-a",
            :private_key_path => File.expand_path("~/.ssh/id_rsa"),
            :public_key_path => File.expand_path("~/.ssh/id_rsa.pub"),<commit_msg>more bad status code checks<commit_after>require 'fog/core/collection'
require 'fog/google/models/compute/server'

module Fog
  module Compute
    class Google

      class Servers < Fog::Collection

        model Fog::Compute::Google::Server

        def all(zone=nil)
          if zone.nil?
            data = []
            service.list_zones.body['items'].each do |zone|
              data += service.list_servers(zone['name']).body["items"] || []
            end
          else
            data = service.list_servers(zone).body["items"] || []
          end
          load(data)
        end

        def get(identity, zone=nil)
          data = nil
          if zone.nil?
            service.list_zones.body['items'].each do |zone|
              response = service.get_server(identity, zone['name'])
              break if response.status == 200
            end
          else
            response = service.get_server(identity, zone)
          end

          if response.status != 200
            nil
          else
            new(response.body)
          end
        rescue Excon::Errors::NotFound
          nil
        end

        def bootstrap(new_attributes = {})
          defaults = {
            :name => "fog-#{Time.now.to_i}",
            :image_name => "debian-7-wheezy-v20130522",
            :machine_type => "n1-standard-1",
            :zone_name => "us-central1-a",
            :private_key_path => File.expand_path("~/.ssh/id_rsa"),
            :public_key_path => File.expand_path("~/.ssh/id_rsa.pub"),
{'fraction_non_alphanumeric': 0.12304177545691906, 'fraction_numerical': 0.01174934725848564, 'mean_word_length': 1.6241438356164384, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5094952', 'n_tokens_mistral': 906, 'n_tokens_neox': 871, 'n_words': 167}