<commit_before>module Glass
  SUBSCRIPTION="subscription"

  # A subscription to events on a collection.
  #
  class Subscription
    class << self
      # The type of resource. This is always mirror#subscription.
      #
      attr_accessor :kind

      ##
      # Subscribe to notifications for the current user.
      #
      # @param [Google::APIClient] client
      #   Authorized client instance.
      # @param [String] collection
      #   Collection to subscribe to (supported values are "timeline" and "locations").
      # @param [String] user_token
      #   Opaque token used by the Glassware to identify the user the notification
      #   pings are sent for (recommended).
      # @param [String] verify_token
      #   Opaque token used by the Glassware to verify that the notification pings are
      #   sent by the API (optional).
      # @param [String] callback_url
      #   URL receiving notification pings (must be HTTPS).
      # @param [Array] operation
      #   List of operations to subscribe to. Valid values are "UPDATE", "INSERT" and
      #   "DELETE" or nil to subscribe to all.
      # @return nil
      def subscribe_to_notification(mirror, collection, user_token, verify_token, callback_url, operation)
        subscription = mirror.subscriptions.insert.request_schema.new({
                                                                          'collection' => collection,
                                                                          'userToken' => user_token,
                                                                          'verifyToken' => verify_token,
                                                                          'callbackUrl' => callback_url,
                                                                          'operation' => operation})
        result = client.execute(
            :api_method => mirror.subscriptions.insert,
            :body_object => subscription)
        if result.error?
          puts "An error occurred: #{result.data['error']['message']}"
        end
      end

    end

    @@kind = MIRROR+"#"+SUBSCRIPTION

    # The ID of the subscription.
    #
    attr_accessor :id
    @id

    # The time at which this subscription was last modified, formatted according to RFC 3339.
    #
    attr_accessor :updated
    @updated

    # The collection to subscribe to. Allowed values are:
    #   timeline - Changes in the timeline including insertion, deletion, and updates.
    #   locations - Location updates.
    attr_accessor :collection
    @collection
    TIMELINE="timeline"
    LOCATIONS="locations"

    # A list of operations that should be subscribed to.
    # An empty list indicates that all operations on the collection should be subscribed to. Allowed values are:
    #   UPDATE - The item has been updated.
    #   INSERT - A new item has been inserted.
    #   DELETE - The item has been deleted.
    attr_accessor :operation
    @operation= []

    # The URL where notifications should be delivered (must start with https://).
    #
    attr_accessor :callbackUrl
    @callbackUrl

    # A secret token sent to the subscriber in notifications
    # so that it can verify that the notification was generated by Google.
    #
    attr_accessor :verifyToken
    @verifyToken

    # An opaque token sent to the subscriber in notifications so that it can determine the ID of the user.
    #
    attr_accessor :userToken
    @userToken

    # Container object for notifications.
    # This is not populated in the Subscription resource.
    #
    attr_accessor :notification
    @notification

    class Notification
      # The collection that generated the notification.
      #
      attr_accessor :collection
      @collection

      # The ID of the item that generated the notification.
      #
      attr_accessor :itemId
      @itemId

      # The type of operation that generated the notification.
      #
      attr_accessor :operation
      @operation

      # The secret verify token provided by the service when it subscribed for notifications.
      #
      attr_accessor :verifyToken
      @verifyToken

      # The user token provided by the service when it subscribed for notifications.
      #
      attr_accessor :userToken
      @userToken

      # A list of actions taken by the user that triggered the notification.
      #
      attr_accessor :userActions
      @userActions=[]

      class Action
        # The type of action. The value of this can be:
        #   SHARE - the user shared an item.
        #   REPLY - the user replied to an item.
        #   REPLY_ALL - the user replied to all recipients of an item.
        #   CUSTOM - the user selected a custom menu item on the timeline item.
        #   DELETE - the user deleted the item.
        #   PIN - the user pinned the item.
        #   UNPIN - the user unpinned the item.
        # In the future, additional types may be added. UserActions with unrecognized types should be ignored.
        #
        attr_accessor :type
        @type

        SHARE="SHARE"
        REPLY="REPLY"
        REPLY_ALL="REPLY_ALL"
        CUSTOM="CUSTOM"
        DELETE="DELETE"
        PIN="PIN"
        UNPIN="UNPIN"

        # An optional payload for the action.
        #
        # For actions of type CUSTOM, this is the ID of the custom menu item that was selected.
        #
        attr_accessor :payload
        @payload

      end

    end

  end<commit_msg>added insert and delete on subscription<commit_after>require 'json'
module Glass
  SUBSCRIPTION="subscription"

  # A subscription to events on a collection.
  #
  class Subscription
    class << self
      # The type of resource. This is always mirror#subscription.
      #
      attr_accessor :kind

      ##
      # Subscribe to notifications for the current user.
      #
      # @param [Google::APIClient] client
      #   Authorized client instance.
      # @param [String] collection
      #   Collection to subscribe to (supported values are "timeline" and "locations").
      # @param [String] user_token
      #   Opaque token used by the Glassware to identify the user the notification
      #   pings are sent for (recommended).
      # @param [String] verify_token
      #   Opaque token used by the Glassware to verify that the notification pings are
      #   sent by the API (optional).
      # @param [String] callback_url
      #   URL receiving notification pings (must be HTTPS).
      # @param [Array] operation
      #   List of operations to subscribe to. Valid values are "UPDATE", "INSERT" and
      #   "DELETE" or nil to subscribe to all.
      # @return nil
      def subscribe(mirror, collection, user_token, verify_token, callback_url, operation)
        subscription = mirror.subscriptions.insert.request_schema.new({
                                                                          'collection' => collection,
                                                                          'userToken' => user_token,
                                                                          'verifyToken' => verify_token,
                                                                          'callbackUrl' => callback_url,
                                                                          'operation' => operation})
        result = client.execute(
            :api_method => mirror.subscriptions.insert,
            :body_object => subscription)
        if result.error?
          puts "An error occurred: #{result.data['error']['message']}"
        end
      end

      ##
      # Delete a subscription to a collection.
      #
      # @param [Google::APIClient] client
      #   Authorized client instance.
      # @param [String] collection
      #   Collection to unsubscribe from (supported values are "timeline" and
      #   "locations").
      # @return nil
      def unsubscribe_from_notifications(client, collection)
        mirror = client.discovered_api('mirror', 'v1')
        result = client.execute(
            :api_method => mirror.subscriptions.delete,
            :parameters => { 'id' => collection })
        if result.error?
          puts "An error occurred: #{result.data['error']['message']}"
        end
      end

    end

    @@kind = MIRROR+"#"+SUBSCRIPTION

    ##
    # The Mirror Api
    #
    attr_accessor :mirror
    @mirror

    # The ID of the subscription.
    #
    attr_accessor :id
    @id

    # The time at which this subscription was last modified, formatted according to RFC 3339.
    #
    attr_accessor :updated
    @updated

    # The collection to subscribe to. Allowed values are:
    #   timeline - Changes in the timeline including insertion, deletion, and updates.
    #   locations - Location updates.
    attr_accessor :collection
    @collection
    TIMELINE="timeline"
    LOCATIONS="locations"

    # A list of operations that should be subscribed to.
    # An empty list indicates that all operations on the collection should be subscribed to. Allowed values are:
    #   UPDATE - The item has been updated.
    #   INSERT - A new item has been inserted.
    #   DELETE - The item has been deleted.
    attr_accessor :operation
    @operation= []

    # The URL where notifications should be delivered (must start with https://).
    #
    attr_accessor :callbackUrl
    @callbackUrl

    # A secret token sent to the subscriber in notifications
    # so that it can verify that the notification was generated by Google.
    #
    attr_accessor :verifyToken
    @verifyToken

    # An opaque token sent to the subscriber in notifications so that it can determine the ID of the user.
    #
    attr_accessor :userToken
    @userToken

    # Container object for notifications.
    # This is not populated in the Subscription resource.
    #
    attr_accessor :notification
    @notification

    class Notification
      # The collection that generated the notification.
      #
      attr_accessor :collection
      @collection

      # The ID of the item that generated the notification.
      #
      attr_accessor :itemId
      @itemId

      # The type of operation that generated the notification.
      #
      attr_accessor :operation
      @operation

      # The secret verify token provided by the service when it subscribed for notifications.
      #
      attr_accessor :verifyToken
      @verifyToken

      # The user token provided by the service when it subscribed for notifications.
      #
      attr_accessor :userToken
      @userToken

      # A list of actions taken by the user that triggered the notification.
      #
      attr_accessor :userActions
      @userActions=[]

      class Action
        # The type of action. The value of this can be:
        #   SHARE - the user shared an item.
        #   REPLY - the user replied to an item.
        #   REPLY_ALL - the user replied to all recipients of an item.
        #   CUSTOM - the user selected a custom menu item on the timeline item.
        #   DELETE - the user deleted the item.
        #   PIN - the user pinned the item.
        #   UNPIN - the user unpinned the item.
        # In the future, additional types may be added. UserActions with unrecognized types should be ignored.
        #
        attr_accessor :type
        @type

        SHARE="SHARE"
        REPLY="REPLY"
        REPLY_ALL="REPLY_ALL"
        CUSTOM="CUSTOM"
        DELETE="DELETE"
        PIN="PIN"
        UNPIN="UNPIN"

        # An optional payload for the action.
        #
        # For actions of type CUSTOM, this is the ID of the custom menu item that was selected.
        #
        attr_accessor :payload
        @payload

      end

      ##
      # Subscribe to notifications for the current user.
      #
      # @param [Google::APIClient] Mirror
      #   Authorized client instance.
      #
      # @return nil
      def insert(mirror=@mirror)
        subscription = mirror.subscriptions.insert.request_schema.new(to_json)
        result = client.execute(
            :api_method => mirror.subscriptions.insert,
            :body_object => subscription)
        if result.error?
          puts "An error occurred: #{result.data['error']['message']}"
        end
      end

      ##
      # Delete a subscription to a collection.
      #
      # @param [Google::APIClient] client
      #   Authorized client instance.
      # @return nil
      def delete(mirror=@mirror)
        result = client.execute(
            :api_method => mirror.subscriptions.delete,
            :parameters => { 'id' => collection })
        if result.error?
          puts "An error occurred: #{result.data['error']['message']}"
        end
      end

    end

  end
{'fraction_non_alphanumeric': 0.06812805551174894, 'fraction_numerical': 0.0007096672449140514, 'mean_word_length': 1.9049473202015574, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4027770', 'n_tokens_mistral': 3239, 'n_tokens_neox': 3128, 'n_words': 1197}