Class: Couchbase::Management::AnalyticsIndexManager

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/management/analytics_index_manager.rb,
/code/couchbase-ruby-client/lib/couchbase/management/analytics_index_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(backend) ⇒ AnalyticsIndexManager

Returns a new instance of AnalyticsIndexManager.

Parameters:

  • backend (Couchbase::Backend)


632
633
634
# File 'lib/couchbase/management/analytics_index_manager.rb', line 632

def initialize(backend)
  @backend = backend
end

Instance Method Details

This method returns an undefined value.

Connects a link

Parameters:

Raises:



761
762
763
# File 'lib/couchbase/management/analytics_index_manager.rb', line 761

def connect_link(options = Options::Analytics::ConnectLink.new)
  @backend.analytics_link_connect(options.to_backend)
end

#create_dataset(dataset_name, bucket_name, options = Options::Analytics::CreateDataset.new) ⇒ void

This method returns an undefined value.

Creates a new dataset

Parameters:

  • dataset_name (String)

    name of dataset

  • bucket_name (String)

    name of the bucket

  • options (Options::Analytics::CreateDataset) (defaults to: Options::Analytics::CreateDataset.new)

Raises:



673
674
675
# File 'lib/couchbase/management/analytics_index_manager.rb', line 673

def create_dataset(dataset_name, bucket_name, options = Options::Analytics::CreateDataset.new)
  @backend.analytics_dataset_create(dataset_name, bucket_name, options.to_backend)
end

#create_dataverse(dataverse_name, options = Options::Analytics::CreateDataverse.new) ⇒ void

This method returns an undefined value.

Creates a new dataverse

Parameters:

Raises:



645
646
647
# File 'lib/couchbase/management/analytics_index_manager.rb', line 645

def create_dataverse(dataverse_name, options = Options::Analytics::CreateDataverse.new)
  @backend.analytics_dataverse_create(dataverse_name, options.to_backend)
end

#create_index(index_name, dataset_name, fields, options = Options::Analytics::CreateIndex.new) ⇒ void

This method returns an undefined value.

Creates a new index

Parameters:

  • index_name (String)

    name of the index

  • dataset_name (String)

    name of the dataset

  • fields (Hash<String => String>)

    mapping of the field name to field type

  • options (Options::Analytics::CreateIndex) (defaults to: Options::Analytics::CreateIndex.new)

Raises:



718
719
720
# File 'lib/couchbase/management/analytics_index_manager.rb', line 718

def create_index(index_name, dataset_name, fields, options = Options::Analytics::CreateIndex.new)
  @backend.analytics_index_create(index_name, dataset_name, fields.entries, options.to_backend)
end

This method returns an undefined value.

Creates a link

Parameters:

Raises:



799
800
801
# File 'lib/couchbase/management/analytics_index_manager.rb', line 799

def create_link(link, options = Options::Analytics::CreateLink.new)
  @backend.analytics_link_create(link.to_backend, options.to_backend)
end

This method returns an undefined value.

Disconnects a link,

Parameters:

Raises:



773
774
775
# File 'lib/couchbase/management/analytics_index_manager.rb', line 773

def disconnect_link(options = Options::Analytics::DisconnectLink.new)
  @backend.analytics_link_disconnect(options.to_backend)
end

#drop_dataset(dataset_name, options = Options::Analytics::DropDataset.new) ⇒ void

This method returns an undefined value.

Drops a dataset

Parameters:

Raises:



686
687
688
# File 'lib/couchbase/management/analytics_index_manager.rb', line 686

def drop_dataset(dataset_name, options = Options::Analytics::DropDataset.new)
  @backend.analytics_dataset_drop(dataset_name, options.to_backend)
end

#drop_dataverse(dataverse_name, options = Options::Analytics::DropDataverse.new) ⇒ void

This method returns an undefined value.

Drops a dataverse

Parameters:

Raises:



658
659
660
# File 'lib/couchbase/management/analytics_index_manager.rb', line 658

def drop_dataverse(dataverse_name, options = Options::Analytics::DropDataverse.new)
  @backend.analytics_dataverse_drop(dataverse_name, options.to_backend)
end

#drop_index(index_name, dataset_name, options = Options::Analytics::DropIndex.new) ⇒ void

This method returns an undefined value.

Drops an index

Parameters:

  • index_name (String)

    name of the index

  • dataset_name (String)

    name of the dataset

  • options (Options::Analytics::DropIndex) (defaults to: Options::Analytics::DropIndex.new)

Raises:



732
733
734
# File 'lib/couchbase/management/analytics_index_manager.rb', line 732

def drop_index(index_name, dataset_name, options = Options::Analytics::DropIndex.new)
  @backend.analytics_index_drop(index_name, dataset_name, options.to_backend)
end

This method returns an undefined value.

Drops the link

Parameters:

  • link_name (String)

    name of the link

  • dataverse_name (String)

    dataverse where the link belongs

  • options (Options::Analytics::DropLink) (defaults to: Options::Analytics::DropLink.new)

Raises:



826
827
828
# File 'lib/couchbase/management/analytics_index_manager.rb', line 826

def drop_link(link_name, dataverse_name, options = Options::Analytics::DropLink.new)
  @backend.analytics_link_drop(link_name, dataverse_name, options.to_backend)
end

#get_all_datasets(options = Options::Analytics::GetAllDatasets.new) ⇒ Array<AnalyticsDataset>

Gets all datasets

Parameters:

Returns:



695
696
697
698
699
700
701
702
703
704
705
# File 'lib/couchbase/management/analytics_index_manager.rb', line 695

def get_all_datasets(options = Options::Analytics::GetAllDatasets.new)
  resp = @backend.analytics_dataset_get_all(options.to_backend)
  resp.map do |entry|
    AnalyticsDataset.new do |dataset|
      dataset.name = entry[:name]
      dataset.dataverse_name = entry[:dataverse_name]
      dataset.link_name = entry[:link_name]
      dataset.bucket_name = entry[:bucket_name]
    end
  end
end

#get_all_indexes(options = Options::Analytics::GetAllIndexes.new) ⇒ Array<AnalyticsIndex>

Gets all indexes

Parameters:

Returns:



741
742
743
744
745
746
747
748
749
750
751
# File 'lib/couchbase/management/analytics_index_manager.rb', line 741

def get_all_indexes(options = Options::Analytics::GetAllIndexes.new)
  resp = @backend.analytics_index_get_all(options.to_backend)
  resp.map do |entry|
    AnalyticsIndex.new do |dataset|
      dataset.name = entry[:name]
      dataset.dataverse_name = entry[:dataverse_name]
      dataset.dataset_name = entry[:dataset_name]
      dataset.is_primary = entry[:is_primary]
    end
  end
end

This method returns an undefined value.

Retrieves the links

Parameters:

Raises:



838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
# File 'lib/couchbase/management/analytics_index_manager.rb', line 838

def get_links(options = Options::Analytics::GetLinks.new)
  resp = @backend.analytics_link_get_all(options.to_backend)
  resp.map do |entry|
    case entry[:type]
    when :s3
      S3ExternalAnalyticsLink.new(
        entry[:link_name],
        entry[:dataverse],
        entry[:access_key_id],
        nil,
        entry[:region],
        service_endpoint: entry[:service_endpoint]
      )
    when :couchbase
      CouchbaseRemoteAnalyticsLink.new(
        entry[:link_name],
        entry[:dataverse],
        entry[:hostname],
        username: entry[:username],
        encryption: EncryptionSettings.new(
          level: entry[:encryption_level],
          certificate: entry[:certificate],
          client_certificate: entry[:client_certificate]
        )
      )
    when :azureblob
      AzureBlobExternalAnalyticsLink.new(
        entry[:link_name],
        entry[:dataverse],
        account_name: entry[:account_name],
        blob_endpoint: entry[:blob_endpoint],
        endpoint_suffix: entry[:endpoint_suffix]
      )
    end
  end
end

#get_pending_mutations(options = Options::Analytics::GetPendingMutations.new) ⇒ Hash<String => Integer>

Note:

If a link is disconnected then it will return no results. If all links are disconnected, then

Gets the pending mutations for all datasets.

an empty object is returned.

Parameters:

Returns:

  • (Hash<String => Integer>)

    dictionary, where keys are dataset coordinates encoded as “dataverse.dataset” and values are number of mutations for given dataset.



786
787
788
# File 'lib/couchbase/management/analytics_index_manager.rb', line 786

def get_pending_mutations(options = Options::Analytics::GetPendingMutations.new)
  @backend.analytics_get_pending_mutations(options.to_backend)
end

This method returns an undefined value.

Replaces the link

Parameters:

Raises:



812
813
814
# File 'lib/couchbase/management/analytics_index_manager.rb', line 812

def replace_link(link, options = Options::Analytics::ReplaceLink.new)
  @backend.analytics_link_replace(link.to_backend, options.to_backend)
end