Sha256: 8fe2590eb1a236cee3d5cf8dfccec05690ffd15d64552679df2e0d1b48bf463d

Contents?: true

Size: 1.88 KB

Versions: 9

Compression:

Stored size: 1.88 KB

Contents

require_relative 'resource'

module Contentful
  module Management
    # Resource class for ApiUsage.
    # @see _ https://www.contentful.com/developers/docs/references/content-management-api/#/reference/api-usages
    class ApiUsage
      include Contentful::Management::Resource
      include Contentful::Management::Resource::Refresher
      include Contentful::Management::Resource::SystemProperties

      property :unitOfMeasure
      property :interval
      property :usage
      property :startDate, :date
      property :endDate, :date

      # @private
      def self.build_endpoint(endpoint_options)
        organization_id = endpoint_options[:organization_id]
        usage_type = endpoint_options[:usage_type]

        "organizations/#{organization_id}/usages/#{usage_type}"
      end

      # Gets all api usage statistics for a given organization and usage type, filtered by usage period and api.
      #
      # @param [Contentful::Management::Client] client
      # @param [String] organization_id
      # @param [String] usage_type
      # @param [Integer] usage_period_id
      # @param [String] api
      # @param [Hash] params
      #
      # @return [Contentful::Management::Array<Contentful::Management::ApiUsage>]
      # rubocop:disable Metrics/ParameterLists
      def self.all(client, organization_id, usage_type, usage_period_id, api, params = {})
        ClientApiUsageMethodsFactory.new(client, organization_id).all(usage_type, usage_period_id, api, params)
      end

      # Not supported
      def self.find(*)
        fail 'Not supported'
      end

      # @private
      def self.endpoint
        'usages'
      end

      # Not supported
      def self.create(*)
        fail 'Not supported'
      end

      # Not supported
      def destroy
        fail 'Not supported'
      end

      # Not supported
      def update(*)
        fail 'Not supported'
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
contentful-management-2.11.0 lib/contentful/management/api_usage.rb
contentful-management-2.10.0 lib/contentful/management/api_usage.rb
contentful-management-2.9.1 lib/contentful/management/api_usage.rb
contentful-management-2.9.0 lib/contentful/management/api_usage.rb
contentful-management-2.8.2 lib/contentful/management/api_usage.rb
contentful-management-2.8.1 lib/contentful/management/api_usage.rb
contentful-management-2.8.0 lib/contentful/management/api_usage.rb
contentful-management-2.7.0 lib/contentful/management/api_usage.rb
contentful-management-2.6.0 lib/contentful/management/api_usage.rb