gbifrb 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +38 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +3 -0
- data/CONDUCT.md +25 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +64 -0
- data/LICENSE +7 -0
- data/README.md +127 -0
- data/Rakefile +41 -0
- data/gbifrb.gemspec +35 -0
- data/lib/gbifrb.rb +48 -0
- data/lib/gbifrb/Occurrences.rb +399 -0
- data/lib/gbifrb/Registry.rb +485 -0
- data/lib/gbifrb/Species.rb +223 -0
- data/lib/gbifrb/constants.rb +36 -0
- data/lib/gbifrb/error.rb +22 -0
- data/lib/gbifrb/faraday.rb +71 -0
- data/lib/gbifrb/get_data.rb +130 -0
- data/lib/gbifrb/helpers/configuration.rb +26 -0
- data/lib/gbifrb/request.rb +51 -0
- data/lib/gbifrb/response.rb +39 -0
- data/lib/gbifrb/utils.rb +60 -0
- data/lib/gbifrb/version.rb +3 -0
- metadata +276 -0
@@ -0,0 +1,485 @@
|
|
1
|
+
require "faraday"
|
2
|
+
require 'faraday_middleware'
|
3
|
+
require "multi_json"
|
4
|
+
require "gbifrb/error"
|
5
|
+
require "gbifrb/request"
|
6
|
+
require "gbifrb/constants"
|
7
|
+
require 'gbifrb/helpers/configuration'
|
8
|
+
require 'gbifrb/faraday'
|
9
|
+
require 'gbifrb/utils'
|
10
|
+
require 'gbifrb/get_data'
|
11
|
+
|
12
|
+
##
|
13
|
+
# Gbif::Registry
|
14
|
+
#
|
15
|
+
# Class to perform HTTP requests to the GBIF API
|
16
|
+
# @!macro gbif_params
|
17
|
+
# @param offset [Fixnum] Number of record to start at, any non-negative integer. Default: 0
|
18
|
+
# @param limit [Fixnum] Number of results to return. Default: 100
|
19
|
+
# @param verbose [Boolean] Print request headers to stdout. Default: false
|
20
|
+
module Gbif
|
21
|
+
module Registry
|
22
|
+
##
|
23
|
+
# Networks metadata
|
24
|
+
#
|
25
|
+
# @param data [String] The type of data to get. Default: 'all'
|
26
|
+
# @param uuid [String] UUID of the data network provider. This must be specified if data
|
27
|
+
# is anything other than 'all'.
|
28
|
+
# @param q [String] Query networks. Only used when 'data = 'all''. Ignored otherwise.
|
29
|
+
# @param identifier [fixnum] The value for this parameter can be a simple string or integer,
|
30
|
+
# e.g. identifier=120
|
31
|
+
# @param identifierType [String] Used in combination with the identifier parameter to filter
|
32
|
+
# identifiers by identifier type: 'DOI', 'FTP', 'GBIF_NODE', 'GBIF_PARTICIPANT',
|
33
|
+
# 'GBIF_PORTAL', 'HANDLER', 'LSID', 'UNKNOWN', 'URI', 'URL', 'UUID'
|
34
|
+
# @!macro gbif_params
|
35
|
+
# @!macro gbif_options
|
36
|
+
#
|
37
|
+
# @return [Hash] A hash
|
38
|
+
#
|
39
|
+
# References: http://www.gbif.org/developer/registry#networks
|
40
|
+
#
|
41
|
+
# @example
|
42
|
+
#
|
43
|
+
# require 'gbifrb'
|
44
|
+
#
|
45
|
+
# registry = Gbif::Registry
|
46
|
+
# registry.networks(limit: 5)
|
47
|
+
# registry.networks(uuid: '16ab5405-6c94-4189-ac71-16ca3b753df7')
|
48
|
+
# registry.networks(data: 'endpoint', uuid: '16ab5405-6c94-4189-ac71-16ca3b753df7')
|
49
|
+
def self.networks(data: 'all', uuid: nil, q: nil, identifier: nil,
|
50
|
+
identifierType: nil, limit: 100, offset: nil, verbose: nil, options: nil)
|
51
|
+
|
52
|
+
arguments = { q: q, limit: limit, offset: offset, identifier: identifier,
|
53
|
+
identifierType: identifierType}.tostrings
|
54
|
+
opts = arguments.delete_if { |k, v| v.nil? }
|
55
|
+
|
56
|
+
data_choices = ['all', 'contact', 'endpoint', 'identifier',
|
57
|
+
'tag', 'machineTag', 'comment', 'constituents']
|
58
|
+
check_data(data, data_choices)
|
59
|
+
return self.getdata_networks(data, uuid, opts, verbose, options)
|
60
|
+
# if len2(data) == 1
|
61
|
+
# return getdata(data, uuid, args)
|
62
|
+
# else
|
63
|
+
# return [getdata(x, uuid, args) for x in data]
|
64
|
+
# end
|
65
|
+
end
|
66
|
+
|
67
|
+
##
|
68
|
+
# Nodes metadata
|
69
|
+
#
|
70
|
+
# @param data [String] The type of data to get. Default: 'all'
|
71
|
+
# @param uuid [String] UUID of the data node provider. This must be specified if data
|
72
|
+
# is anything other than 'all'.
|
73
|
+
# @param q [String] Query nodes. Only used when 'data = 'all''
|
74
|
+
# @param identifier [fixnum] The value for this parameter can be a simple string or integer,
|
75
|
+
# e.g. identifier=120
|
76
|
+
# @param identifierType [String] Used in combination with the identifier parameter to filter
|
77
|
+
# identifiers by identifier type: 'DOI', 'FTP', 'GBIF_NODE', 'GBIF_PARTICIPANT',
|
78
|
+
# 'GBIF_PORTAL', 'HANDLER', 'LSID', 'UNKNOWN', 'URI', 'URL', 'UUID'
|
79
|
+
# @param isocode [String] A 2 letter country code. Only used if 'data = 'country''.
|
80
|
+
# @!macro gbif_params
|
81
|
+
# @!macro gbif_options
|
82
|
+
#
|
83
|
+
# @return [Hash] A hash
|
84
|
+
#
|
85
|
+
# References http://www.gbif.org/developer/registry#nodes
|
86
|
+
#
|
87
|
+
# @example
|
88
|
+
#
|
89
|
+
# require 'gbifrb'
|
90
|
+
#
|
91
|
+
# registry = Gbif::Registry
|
92
|
+
# registry.nodes(limit: 5)
|
93
|
+
# registry.nodes(identifier: 120)
|
94
|
+
# registry.nodes(uuid: "1193638d-32d1-43f0-a855-8727c94299d8")
|
95
|
+
# registry.nodes(data: 'identifier', uuid: "03e816b3-8f58-49ae-bc12-4e18b358d6d9")
|
96
|
+
# # FIXME: not working yet
|
97
|
+
# # registry.nodes(data: ['identifier','organization','comment'], uuid: "03e816b3-8f58-49ae-bc12-4e18b358d6d9")
|
98
|
+
#
|
99
|
+
#
|
100
|
+
# uuids = ["8cb55387-7802-40e8-86d6-d357a583c596","02c40d2a-1cba-4633-90b7-e36e5e97aba8",
|
101
|
+
# "7a17efec-0a6a-424c-b743-f715852c3c1f","b797ce0f-47e6-4231-b048-6b62ca3b0f55",
|
102
|
+
# "1193638d-32d1-43f0-a855-8727c94299d8","d3499f89-5bc0-4454-8cdb-60bead228a6d",
|
103
|
+
# "cdc9736d-5ff7-4ece-9959-3c744360cdb3","a8b16421-d80b-4ef3-8f22-098b01a89255",
|
104
|
+
# "8df8d012-8e64-4c8a-886e-521a3bdfa623","b35cf8f1-748d-467a-adca-4f9170f20a4e",
|
105
|
+
# "03e816b3-8f58-49ae-bc12-4e18b358d6d9","073d1223-70b1-4433-bb21-dd70afe3053b",
|
106
|
+
# "07dfe2f9-5116-4922-9a8a-3e0912276a72","086f5148-c0a8-469b-84cc-cce5342f9242",
|
107
|
+
# "0909d601-bda2-42df-9e63-a6d51847ebce","0e0181bf-9c78-4676-bdc3-54765e661bb8",
|
108
|
+
# "109aea14-c252-4a85-96e2-f5f4d5d088f4","169eb292-376b-4cc6-8e31-9c2c432de0ad",
|
109
|
+
# "1e789bc9-79fc-4e60-a49e-89dfc45a7188","1f94b3ca-9345-4d65-afe2-4bace93aa0fe"]
|
110
|
+
#
|
111
|
+
# # [ registry.nodes(data: 'identifier', uuid: x) for x in uuids ] # not working yet
|
112
|
+
def self.nodes(data: 'all', uuid: nil, q: nil, identifier: nil,
|
113
|
+
identifierType: nil, limit: 100, offset: nil, isocode: nil,
|
114
|
+
verbose: nil, options: nil)
|
115
|
+
|
116
|
+
arguments = { q: q, limit: limit, offset: offset, identifier: identifier,
|
117
|
+
identifierType: identifierType }.tostrings
|
118
|
+
opts = arguments.delete_if { |k, v| v.nil? }
|
119
|
+
data_choices = ['all', 'organization', 'endpoint',
|
120
|
+
'identifier', 'tag', 'machineTag', 'comment',
|
121
|
+
'pendingEndorsement', 'country', 'dataset', 'installation']
|
122
|
+
check_data(data, data_choices)
|
123
|
+
return self.getdata_nodes(data, uuid, opts, isocode, verbose, options)
|
124
|
+
# if len2(data) == 1
|
125
|
+
# return self.getdata_nodes(data, uuid, args)
|
126
|
+
# else
|
127
|
+
# return [self.getdata_nodes(x, uuid, args) for x in data]
|
128
|
+
# end
|
129
|
+
end
|
130
|
+
|
131
|
+
##
|
132
|
+
# Organizations metadata
|
133
|
+
#
|
134
|
+
# @param data [String] The type of data to get. Default is all data. If not 'all', then one
|
135
|
+
# or more of 'contact', 'endpoint', 'identifier', 'tag', 'machineTag',
|
136
|
+
# 'comment', 'hostedDataset', 'ownedDataset', 'deleted', 'pending',
|
137
|
+
# 'nonPublishing'.
|
138
|
+
# @param uuid [String] UUID of the data node provider. This must be specified if data
|
139
|
+
# is anything other than 'all'.
|
140
|
+
# @param q [String] Query nodes. Only used when 'data='all''. Ignored otherwise.
|
141
|
+
# @param identifier [fixnum] The value for this parameter can be a simple string or integer,
|
142
|
+
# e.g. identifier=120
|
143
|
+
# @param identifierType [String] Used in combination with the identifier parameter to filter
|
144
|
+
# identifiers by identifier type: 'DOI', 'FTP', 'GBIF_NODE', 'GBIF_PARTICIPANT',
|
145
|
+
# 'GBIF_PORTAL', 'HANDLER', 'LSID', 'UNKNOWN', 'URI', 'URL', 'UUID'
|
146
|
+
# @!macro gbif_params
|
147
|
+
# @!macro gbif_options
|
148
|
+
#
|
149
|
+
# @return [Hash] a hash
|
150
|
+
#
|
151
|
+
# References: http://www.gbif.org/developer/registry#organizations
|
152
|
+
#
|
153
|
+
# @example
|
154
|
+
#
|
155
|
+
# require 'gbifrb'
|
156
|
+
#
|
157
|
+
# registry = Gbif::Registry
|
158
|
+
# registry.organizations(limit: 5)
|
159
|
+
# registry.organizations(q: "france")
|
160
|
+
# registry.organizations(identifier: 120)
|
161
|
+
# registry.organizations(uuid: "e2e717bf-551a-4917-bdc9-4fa0f342c530")
|
162
|
+
# registry.organizations(data: 'contact', uuid: "e2e717bf-551a-4917-bdc9-4fa0f342c530")
|
163
|
+
# registry.organizations(data: 'endpoint', uuid: "e2e717bf-551a-4917-bdc9-4fa0f342c530")
|
164
|
+
# registry.organizations(data: 'deleted')
|
165
|
+
# registry.organizations(data: 'deleted', limit: 2)
|
166
|
+
# registry.organizations(identifierType: 'DOI', limit: 2)
|
167
|
+
# # FIXME: doesn't work yet
|
168
|
+
# # registry.organizations(data: ['deleted','nonPublishing'], limit: 2)
|
169
|
+
def self.organizations(data: 'all', uuid: nil, q: nil, identifier: nil,
|
170
|
+
identifierType: nil, limit: 100, offset: nil,
|
171
|
+
verbose: nil, options: nil)
|
172
|
+
|
173
|
+
arguments = { q: q, limit: limit, offset: offset, identifier: identifier,
|
174
|
+
identifierType: identifierType }.tostrings
|
175
|
+
opts = arguments.delete_if { |k, v| v.nil? }
|
176
|
+
data_choices = ['all', 'contact', 'endpoint',
|
177
|
+
'identifier', 'tag', 'machineTag', 'comment', 'hostedDataset',
|
178
|
+
'ownedDataset', 'deleted', 'pending', 'nonPublishing']
|
179
|
+
check_data(data, data_choices)
|
180
|
+
self.getdata_orgs(data, uuid, opts, verbose, options)
|
181
|
+
# if len2(data) == 1
|
182
|
+
# return self.getdata_orgs(data, uuid, args, **kwargs)
|
183
|
+
# else
|
184
|
+
# return [self.getdata_orgs(x, uuid, args, **kwargs) for x in data]
|
185
|
+
# end
|
186
|
+
end
|
187
|
+
|
188
|
+
##
|
189
|
+
# Installations metadata.
|
190
|
+
#
|
191
|
+
# @param data [String] The type of data to get. Default is all data. If not 'all', then one
|
192
|
+
# or more of 'contact', 'endpoint', 'dataset', 'comment', 'deleted', 'nonPublishing'.
|
193
|
+
# @param uuid [String] UUID of the data node provider. This must be specified if data
|
194
|
+
# is anything other than 'all'.
|
195
|
+
# @param q [String] Query nodes. Only used when 'data='all''. Ignored otherwise.
|
196
|
+
# @param identifier [fixnum] The value for this parameter can be a simple string or integer,
|
197
|
+
# e.g. identifier=120
|
198
|
+
# @param identifierType [String] Used in combination with the identifier parameter to filter
|
199
|
+
# identifiers by identifier type: 'DOI', 'FTP', 'GBIF_NODE', 'GBIF_PARTICIPANT',
|
200
|
+
# 'GBIF_PORTAL', 'HANDLER', 'LSID', 'UNKNOWN', 'URI', 'URL', 'UUID'
|
201
|
+
# @!macro gbif_params
|
202
|
+
# @!macro gbif_options
|
203
|
+
#
|
204
|
+
# @return [Hash] a hash
|
205
|
+
#
|
206
|
+
# References: http://www.gbif.org/developer/registry#installations
|
207
|
+
#
|
208
|
+
# @example
|
209
|
+
#
|
210
|
+
# require 'gbifrb'
|
211
|
+
#
|
212
|
+
# registry = Gbif::Registry
|
213
|
+
# registry.installations(limit: 5)
|
214
|
+
# registry.installations(q: "france")
|
215
|
+
# registry.installations(uuid: "b77901f9-d9b0-47fa-94e0-dd96450aa2b4")
|
216
|
+
# registry.installations(data: 'contact', uuid: "b77901f9-d9b0-47fa-94e0-dd96450aa2b4")
|
217
|
+
# registry.installations(data: 'contact', uuid: "2e029a0c-87af-42e6-87d7-f38a50b78201")
|
218
|
+
# registry.installations(data: 'endpoint', uuid: "b77901f9-d9b0-47fa-94e0-dd96450aa2b4")
|
219
|
+
# registry.installations(data: 'dataset', uuid: "b77901f9-d9b0-47fa-94e0-dd96450aa2b4")
|
220
|
+
# registry.installations(data: 'deleted')
|
221
|
+
# registry.installations(data: 'deleted', limit: 2)
|
222
|
+
# registry.installations(identifierType: 'DOI', limit: 2)
|
223
|
+
# # FIXME: doesn't work yet
|
224
|
+
# # registry.installations(data: ['deleted','nonPublishing'], limit: 2)
|
225
|
+
def self.installations(data: 'all', uuid: nil, q: nil, identifier: nil,
|
226
|
+
identifierType: nil, limit: 100, offset: nil, verbose: nil, options: nil)
|
227
|
+
|
228
|
+
arguments = { q: q, limit: limit, offset: offset, identifier: identifier,
|
229
|
+
identifierType: identifierType }.tostrings
|
230
|
+
opts = arguments.delete_if { |k, v| v.nil? }
|
231
|
+
data_choices = ['all', 'contact', 'endpoint', 'dataset',
|
232
|
+
'identifier', 'tag', 'machineTag', 'comment',
|
233
|
+
'deleted', 'nonPublishing']
|
234
|
+
check_data(data, data_choices)
|
235
|
+
self.getdata_installations(data, uuid, opts, verbose, options)
|
236
|
+
# if len2(data) == 1
|
237
|
+
# return self.getdata_installations(data, uuid, opts, verbose, options)
|
238
|
+
# else
|
239
|
+
# return [self.getdata_installations(x, uuid, opts, verbose, options) for x in data]
|
240
|
+
# end
|
241
|
+
end
|
242
|
+
|
243
|
+
##
|
244
|
+
# Get details on a GBIF dataset.
|
245
|
+
#
|
246
|
+
# @param uuid [String] One or more dataset UUIDs. See examples.
|
247
|
+
# @!macro gbif_options
|
248
|
+
#
|
249
|
+
# References: http://www.gbif.org/developer/registry#datasetMetrics
|
250
|
+
#
|
251
|
+
# @example
|
252
|
+
#
|
253
|
+
# require 'gbifrb'
|
254
|
+
#
|
255
|
+
# registry = Gbif::Registry
|
256
|
+
# registry.dataset_metrics(uuid: '3f8a1297-3259-4700-91fc-acc4170b27ce')
|
257
|
+
# registry.dataset_metrics(uuid: '66dd0960-2d7d-46ee-a491-87b9adcfe7b1')
|
258
|
+
# # registry.dataset_metrics(uuid: ['3f8a1297-3259-4700-91fc-acc4170b27ce', '66dd0960-2d7d-46ee-a491-87b9adcfe7b1'])
|
259
|
+
def self.dataset_metrics(uuid:, verbose: nil, options: nil)
|
260
|
+
if len2(uuid) == 1
|
261
|
+
return self.getdata_dataset_metrics(uuid, verbose, options)
|
262
|
+
else
|
263
|
+
raise "not ready yet"
|
264
|
+
# return [self.getdata_dataset_metrics(x, verbose, options) for x in uuid]
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
##
|
269
|
+
# Search for datasets and dataset metadata.
|
270
|
+
#
|
271
|
+
# @param data [String] The type of data to get. Default: 'all'
|
272
|
+
# @param type [String] Type of dataset, options include 'OCCURRENCE', etc.
|
273
|
+
# @param uuid [String] UUID of the data node provider. This must be specified if data
|
274
|
+
# is anything other than 'all'.
|
275
|
+
# @param query [String] Query term(s). Only used when 'data = 'all''
|
276
|
+
# @param id [int] A metadata document id.
|
277
|
+
# @!macro gbif_params
|
278
|
+
# @!macro gbif_options
|
279
|
+
#
|
280
|
+
# References http://www.gbif.org/developer/registry#datasets
|
281
|
+
#
|
282
|
+
# @example
|
283
|
+
#
|
284
|
+
# require 'gbifrb'
|
285
|
+
#
|
286
|
+
# registry = Gbif::Registry
|
287
|
+
# registry.datasets(limit: 5)
|
288
|
+
# registry.datasets(type: "OCCURRENCE")
|
289
|
+
# registry.datasets(uuid: "a6998220-7e3a-485d-9cd6-73076bd85657")
|
290
|
+
# registry.datasets(data: 'contact', uuid: "a6998220-7e3a-485d-9cd6-73076bd85657")
|
291
|
+
# registry.datasets(data: 'metadata', uuid: "a6998220-7e3a-485d-9cd6-73076bd85657")
|
292
|
+
# registry.datasets(data: 'metadata', uuid: "a6998220-7e3a-485d-9cd6-73076bd85657", id: 598)
|
293
|
+
# # registry.datasets(data: ['deleted','duplicate'])
|
294
|
+
# # registry.datasets(data: ['deleted','duplicate'], limit=1)
|
295
|
+
def self.datasets(data: 'all', type: nil, uuid: nil, query: nil, id: nil,
|
296
|
+
limit: 100, offset: nil, verbose: nil, options: nil)
|
297
|
+
|
298
|
+
arguments = { q: query, type: type, limit: limit, offset: offset}.tostrings
|
299
|
+
opts = arguments.delete_if { |k, v| v.nil? }
|
300
|
+
data_choices = ['all', 'organization', 'contact', 'endpoint',
|
301
|
+
'identifier', 'tag', 'machinetag', 'comment',
|
302
|
+
'constituents', 'document', 'metadata', 'deleted',
|
303
|
+
'duplicate', 'subDataset', 'withNoEndpoint']
|
304
|
+
check_data(data, data_choices)
|
305
|
+
if len2(data) == 1
|
306
|
+
return self.datasets_fetch(data, uuid, opts, verbose, options)
|
307
|
+
else
|
308
|
+
raise "not ready yet"
|
309
|
+
# return [self.datasets_fetch(x, uuid, args, **kwargs) for x in data]
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
##
|
314
|
+
# Search that returns up to 20 matching datasets. Results are ordered by relevance.
|
315
|
+
#
|
316
|
+
# @param q [String] Query term(s) for full text search. The value for this parameter can be a simple word or a phrase. Wildcards can be added to the simple word parameters only, e.g. 'q=*puma*'
|
317
|
+
# @param type [String] Type of dataset, options include OCCURRENCE, etc.
|
318
|
+
# @param keyword [String] Keyword to search by. Datasets can be tagged by keywords, which you can search on. The search is done on the merged collection of tags, the dataset keywordCollections and temporalCoverages. SEEMS TO NOT BE WORKING ANYMORE AS OF 2016-09-02.
|
319
|
+
# @param owningOrg [String] Owning organization. A uuid string. See :func:`~pygbif.registry.organizations`
|
320
|
+
# @param publishingOrg [String] Publishing organization. A uuid string. See :func:`~pygbif.registry.organizations`
|
321
|
+
# @param hostingOrg [String] Hosting organization. A uuid string. See :func:`~pygbif.registry.organizations`
|
322
|
+
# @param publishingCountry [String] Publishing country.
|
323
|
+
# @param decade [String] Decade, e.g., 1980. Filters datasets by their temporal coverage broken down to decades. Decades are given as a full year, e.g. 1880, 1960, 2000, etc, and will return datasets wholly contained in the decade as well as those that cover the entire decade or more. Facet by decade to get the break down, e.g. '/search?facet=DECADE&facet_only=true' (see example below)
|
324
|
+
# @param limit [int] Number of results to return. Default: '300'
|
325
|
+
# @param offset [int] Record to start at. Default: '0'
|
326
|
+
# @!macro gbif_options
|
327
|
+
#
|
328
|
+
# @return [Hash] a hash
|
329
|
+
#
|
330
|
+
# References: http://www.gbif.org/developer/registry#datasetSearch
|
331
|
+
#
|
332
|
+
# @example
|
333
|
+
#
|
334
|
+
# require 'gbifrb'
|
335
|
+
#
|
336
|
+
# registry = Gbif::Registry
|
337
|
+
# registry.dataset_suggest(q: "Amazon", type: "OCCURRENCE")
|
338
|
+
#
|
339
|
+
# # Suggest datasets tagged with keyword "france".
|
340
|
+
# registry.dataset_suggest(keyword: "france")
|
341
|
+
#
|
342
|
+
# # Suggest datasets owned by the organization with key
|
343
|
+
# # "07f617d0-c688-11d8-bf62-b8a03c50a862" (UK NBN).
|
344
|
+
# registry.dataset_suggest(owningOrg: "07f617d0-c688-11d8-bf62-b8a03c50a862")
|
345
|
+
#
|
346
|
+
# # Fulltext search for all datasets having the word "amsterdam" somewhere in
|
347
|
+
# # its metadata (title, description, etc).
|
348
|
+
# registry.dataset_suggest(q: "amsterdam")
|
349
|
+
#
|
350
|
+
# # Limited search
|
351
|
+
# registry.dataset_suggest(type: "OCCURRENCE", limit: 2)
|
352
|
+
# registry.dataset_suggest(type: "OCCURRENCE", limit: 2, offset: 10)
|
353
|
+
#
|
354
|
+
# # Return just descriptions
|
355
|
+
# registry.dataset_suggest(type: "OCCURRENCE", limit: 5, description: True)
|
356
|
+
#
|
357
|
+
# # Search by decade
|
358
|
+
# registry.dataset_suggest(decade: 1980, limit: 30)
|
359
|
+
def self.dataset_suggest(q: nil, type: nil, keyword: nil, owningOrg: nil,
|
360
|
+
publishingOrg: nil, hostingOrg: nil, publishingCountry: nil, decade: nil,
|
361
|
+
limit: 100, offset: nil, verbose: nil, options: nil)
|
362
|
+
|
363
|
+
arguments = { q: q, type: type, keyword: keyword,
|
364
|
+
publishingOrg: publishingOrg, hostingOrg: hostingOrg,
|
365
|
+
owningOrg: owningOrg, decade: decade,
|
366
|
+
publishingCountry: publishingCountry,
|
367
|
+
limit: limit, offset: offset}.tostrings
|
368
|
+
opts = arguments.delete_if { |k, v| v.nil? }
|
369
|
+
Request.new('dataset/suggest', opts, verbose, options).perform
|
370
|
+
end
|
371
|
+
|
372
|
+
##
|
373
|
+
# Full text search across all datasets. Results are ordered by relevance.
|
374
|
+
#
|
375
|
+
# @param q [String] Query term(s) for full text search. The value for this parameter
|
376
|
+
# can be a simple word or a phrase. Wildcards can be added to the simple word
|
377
|
+
# parameters only, e.g. 'q=*puma*'
|
378
|
+
# @param type [String] Type of dataset, options include OCCURRENCE, etc.
|
379
|
+
# @param keyword [String] Keyword to search by. Datasets can be tagged by keywords, which
|
380
|
+
# you can search on. The search is done on the merged collection of tags, the
|
381
|
+
# dataset keywordCollections and temporalCoverages. SEEMS TO NOT BE WORKING
|
382
|
+
# ANYMORE AS OF 2016-09-02.
|
383
|
+
# @param owningOrg [String] Owning organization. A uuid string. See :func:`~pygbif.registry.organizations`
|
384
|
+
# @param publishingOrg [String] Publishing organization. A uuid string. See :func:`~pygbif.registry.organizations`
|
385
|
+
# @param hostingOrg [String] Hosting organization. A uuid string. See :func:`~pygbif.registry.organizations`
|
386
|
+
# @param publishingCountry [String] Publishing country.
|
387
|
+
# @param decade [String] Decade, e.g., 1980. Filters datasets by their temporal coverage
|
388
|
+
# broken down to decades. Decades are given as a full year, e.g. 1880, 1960, 2000,
|
389
|
+
# etc, and will return datasets wholly contained in the decade as well as those
|
390
|
+
# that cover the entire decade or more. Facet by decade to get the break down,
|
391
|
+
# e.g. '/search?facet=DECADE&facet_only=true' (see example below)
|
392
|
+
# @param facet [String] A list of facet names used to retrieve the 100 most frequent values
|
393
|
+
# for a field. Allowed facets are: type, keyword, publishingOrg, hostingOrg, decade,
|
394
|
+
# and publishingCountry. Additionally subtype and country are legal values but not
|
395
|
+
# yet implemented, so data will not yet be returned for them.
|
396
|
+
# @param facetMincount [String] Used in combination with the facet parameter. Set
|
397
|
+
# facetMincount={#} to exclude facets with a count less than {#}, e.g.
|
398
|
+
# http://api.gbif.org/v1/dataset/search?facet=type&limit=0&facetMincount=10000
|
399
|
+
# only shows the type value 'OCCURRENCE' because 'CHECKLIST' and 'METADATA' have
|
400
|
+
# counts less than 10000.
|
401
|
+
# @param facetMultiselect [bool] Used in combination with the facet parameter. Set
|
402
|
+
# facetMultiselect=True to still return counts for values that are not currently
|
403
|
+
# filtered, e.g.
|
404
|
+
# http://api.gbif.org/v1/dataset/search?facet=type&limit=0&type=CHECKLIST&facetMultiselect=true
|
405
|
+
# still shows type values 'OCCURRENCE' and 'METADATA' even though type is being
|
406
|
+
# filtered by type=CHECKLIST
|
407
|
+
# @param hl [bool] Set 'hl=True' to highlight terms matching the query when in fulltext
|
408
|
+
# search fields. The highlight will be an emphasis tag of class 'gbifH1' e.g.
|
409
|
+
# http://api.gbif.org/v1/dataset/search?q=plant&hl=true
|
410
|
+
# Fulltext search fields include: title, keyword, country, publishing country,
|
411
|
+
# publishing organization title, hosting organization title, and description. One
|
412
|
+
# additional full text field is searched which includes information from metadata
|
413
|
+
# documents, but the text of this field is not returned in the response.
|
414
|
+
# @param limit [int] Number of results to return. Default: '300'
|
415
|
+
# @param offset [int] Record to start at. Default: '0'
|
416
|
+
# @!macro gbif_options
|
417
|
+
#
|
418
|
+
# @note Note that you can pass in additional faceting parameters on a per field basis.
|
419
|
+
# For example, if you want to limit the numbef of facets returned from a field 'foo' to
|
420
|
+
# 3 results, pass in 'foo_facetLimit = 3'. GBIF does not allow all per field parameters,
|
421
|
+
# but does allow some. See also examples.
|
422
|
+
#
|
423
|
+
# @return [Hash] a hash
|
424
|
+
#
|
425
|
+
# References: http://www.gbif.org/developer/registry#datasetSearch
|
426
|
+
#
|
427
|
+
# @example
|
428
|
+
#
|
429
|
+
# require 'gbifrb'
|
430
|
+
#
|
431
|
+
# registry = Gbif::Registry
|
432
|
+
#
|
433
|
+
# # Gets all datasets of type "OCCURRENCE".
|
434
|
+
# registry.dataset_search(type: "OCCURRENCE", limit: 10)
|
435
|
+
#
|
436
|
+
# # Fulltext search for all datasets having the word "amsterdam" somewhere in
|
437
|
+
# # its metadata (title, description, etc).
|
438
|
+
# registry.dataset_search(q: "amsterdam", limit: 10)
|
439
|
+
#
|
440
|
+
# # Limited search
|
441
|
+
# registry.dataset_search(type: "OCCURRENCE", limit: 2)
|
442
|
+
# registry.dataset_search(type: "OCCURRENCE", limit: 2, offset: 10)
|
443
|
+
#
|
444
|
+
# # Search by decade
|
445
|
+
# registry.dataset_search(decade: 1980, limit: 10)
|
446
|
+
#
|
447
|
+
# # Faceting
|
448
|
+
# ## just facets
|
449
|
+
# registry.dataset_search(facet: "decade", facetMincount: 10, limit: 0)
|
450
|
+
#
|
451
|
+
# ## data and facets
|
452
|
+
# registry.dataset_search(facet: "decade", facetMincount: 10, limit: 2)
|
453
|
+
#
|
454
|
+
# ## many facet variables
|
455
|
+
# registry.dataset_search(facet: ["decade", "type"], facetMincount: 10, limit: 0)
|
456
|
+
#
|
457
|
+
# ## facet vars
|
458
|
+
# ### per variable paging
|
459
|
+
# registry.dataset_search(
|
460
|
+
# facet: ["decade", "type"],
|
461
|
+
# decade_facetLimit: 3,
|
462
|
+
# type_facetLimit: 3,
|
463
|
+
# limit: 0
|
464
|
+
# )
|
465
|
+
#
|
466
|
+
# ## highlight
|
467
|
+
# registry.dataset_search(q: "plant", hl: True, limit : 10)
|
468
|
+
def self.dataset_search(q: nil, type: nil, keyword: nil,
|
469
|
+
owningOrg: nil, publishingOrg: nil, hostingOrg: nil, decade: nil,
|
470
|
+
publishingCountry: nil, facet: nil, facetMincount: nil,
|
471
|
+
facetMultiselect: nil, hl: false, limit: 100, offset: nil,
|
472
|
+
verbose: nil, options: nil)
|
473
|
+
|
474
|
+
arguments = {q: q, type: type, keyword: keyword,
|
475
|
+
owningOrg: owningOrg, publishingOrg: publishingOrg,
|
476
|
+
hostingOrg: hostingOrg, decade: decade,
|
477
|
+
publishingCountry: publishingCountry, facet: facet,
|
478
|
+
facetMincount: facetMincount, facetMultiselect: facetMultiselect,
|
479
|
+
hl: hl, limit: limit, offset: offset}.tostrings
|
480
|
+
opts = arguments.delete_if { |k, v| v.nil? }
|
481
|
+
Request.new('dataset/search', opts, verbose, options).perform
|
482
|
+
end
|
483
|
+
|
484
|
+
end
|
485
|
+
end
|