Seismic Drive Client API
SDUtils.h
Go to the documentation of this file.
1 // ============================================================================
2 // Copyright 2017-2023, Schlumberger
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 // ============================================================================
16 
17 #pragma once
18 
19 #include "DLL_EXPORT.h"
20 
21 #include <string>
22 #include <vector>
23 
24 #include "SDManager.h"
25 
26 namespace seismicdrive
27 {
28  /*******************************************************************************/
36  class DLL_PUBLIC SDUtils
37  {
38  public:
39  /*******************************************************************************/
45  SDUtils(SDManager *sdmanager);
46 
47  /*******************************************************************************/
53  ~SDUtils();
54 
55  /*******************************************************************************/
62  SDUtils(SDUtils &&rhf) noexcept;
63 
64  /*******************************************************************************/
70  SDUtils &operator=(SDUtils &&rhf) noexcept;
71 
72  /*******************************************************************************/
79  SDUtils(const SDUtils &rhs);
80 
81  /*******************************************************************************/
87  SDUtils &operator=(const SDUtils &rhs);
88 
89  /*******************************************************************************/
100  std::vector<bool> datasetsExist(const std::vector<std::string> &sdfileNames);
101 
102  /*******************************************************************************/
108  bool datasetExist(const std::string &fileName);
109 
110  /*******************************************************************************/
120  bool datasetExists(const std::string &fileName);
121 
122  /*******************************************************************************/
128  std::vector<int64_t> datasetsSize(const std::vector<std::string> &sdfileNames);
129 
130  /*******************************************************************************/
141  std::vector<int64_t> datasetSizes(const std::vector<std::string> &sdfileNames);
142 
143  /*******************************************************************************/
153  int64_t datasetSize(const std::string &fileName);
154 
155  /*******************************************************************************/
168  void deleteDataset(const std::string &sddatasetname);
169 
170  /*******************************************************************************/
179  void deleteDatasetSync(const std::string &datasetUri);
180 
181  /*******************************************************************************/
192  bool blockExists(const std::string &datasetpath, int blocknum) const;
193 
194  /*******************************************************************************/
205  bool blockExists(const std::string &datasetpath, const std::string &blockName) const;
206 
207  /*******************************************************************************/
216  std::vector<std::vector<std::string>> readDirectory(const std::string &sddirectorypath) const;
217 
218  /*******************************************************************************/
246  std::pair<std::vector<std::string>, std::vector<std::string>> ls(const std::string &path, std::string& cursor, int limit=10000) const;
247 
248  /*******************************************************************************/
272  std::vector<std::string> datasetList(const std::string &subProjectPath, std::string& cursor, int limit=100) const;
273 
274  /*******************************************************************************/
293  std::string bulkDelete(const std::string &path) const;
294 
295  /*******************************************************************************/
313  std::string bulkDeleteSubProjectPath(std::string &subProjectPath) const;
314 
315  /*******************************************************************************/
333  std::string bulkDeleteDataset(std::string &datasetPath) const;
334 
335  /*******************************************************************************/
355  BulkDeleteStatus bulkDeleteStatus(const std::string &operationId, const std::string &dataPartitionId) const;
356 
357  /*******************************************************************************/
377  std::string bulkChangeTier(const std::string &path, const std::string &storageTier) const;
378 
379  /*******************************************************************************/
397  std::string bulkChangeTierSubProjectPath(std::string &subProjectPath, const std::string &storageTier) const;
398 
399  /*******************************************************************************/
417  std::string bulkChangeTierDataset(std::string &datasetPath, const std::string &storageTier) const;
418 
419  /*******************************************************************************/
439  BulkChangeTierStatus bulkChangeTierStatus(const std::string &operationId, const std::string &dataPartitionId) const;
440 
441  /*******************************************************************************/
448  std::string getServiceCloudProivider() const;
449 
450  /*******************************************************************************
451  * @brief Upload a file
452  *
453  * This method can be used to upload a file into a single object
454  *
455  * prerequisites:
456  * The dataset must not been open
457  * File to upload must exist
458  *
459  * usage example:
460 
461  * - std::string fileToUpload = "/path/to/your.file"
462  * - std::ifstream infile(fileToUpload);
463  * - if(!infile.good())
464  * - return 0
465  *
466  * - SDManager sdmanager;
467  * - SDUtils utils(&sdmanager);
468  * - utils.upload("sd://tenant/subproject/path/your.file", fileToUpload);
469  *
470  * @param datasetpath is the seismic drive dataset name ( sd://tenant/subproject/path/dataset )
471  * @param filename is the path of the file to upload
472  *
473  * failure mode:
474  * @throw error::dataset::Error if dataset is currently open
475  ******************************************************************************/
476  void upload(const std::string &datasetpath, const std::string &filename) const;
477 
478  /*******************************************************************************/
488  static bool isSDDatasetPath(const std::string &datasetpath);
489 
490  /*******************************************************************************/
505  std::string getCreatedDate(const std::string &seistoreDatasetPath) const;
506 
507  /*******************************************************************************/
522  std::string getLastModifiedDate(const std::string &seistoreDatasetPath) const;
523 
524  /*******************************************************************************/
539  std::string getCreatedBy(const std::string &seistoreDatasetPath) const;
540 
541  /*******************************************************************************/
556  std::string getType(const std::string &seistoreDatasetPath) const;
557 
558  /*******************************************************************************/
573  std::string getLegalTag(const std::string &seistoreDatasetPath) const;
574 
575  /*******************************************************************************/
588  std::string getFileMetaData(const std::string &seistoreDatasetPath) const;
589 
590  /*******************************************************************************/
604  void datasetUnlock(const std::string &seistoreDatasetPath) const;
605 
606  /*******************************************************************************/
624  std::string getOpenSessionID(const std::string &seistoreDatasetPath) const;
625 
626  /*******************************************************************************
627  * @brief Update the StorageTier of a dataset
628  *
629  * This method can be used to update all of a dataset's blobs to an available storage tier
630  *
631  * usage example:
632  * - SDManager sdmanager;
633  * - SDUtils utils(&sdmanager);
634  * - utils.updateStorageTier(path, StorageTier::COOL);
635  *
636  * @param sdpath is the seismic-store dataset path
637  * @param storageTier is the storage tier the dataset to chanage to
638  *
639  * @return A bool value representing the completion of storage tier change operation.
640  ******************************************************************************/
641  bool updateStorageTier(const std::string &sdpath, const std::string &storageTier) const;
642 
643  private:
644 #ifdef _MSC_VER
645  #pragma warning(push)
646  #pragma warning(disable : 4251)
647 #endif
648 
649  class Impl;
650 
651  std::unique_ptr<Impl> _impl;
652 
653 #ifdef _MSC_VER
654  #pragma warning(pop)
655 #endif
656 
657  friend class SDUtilsTest;
658  };
659 }
Defines operation BulkChangeTier Status.
Definition: Types.h:40
Definition: SDManager.h:27
Definition: Constants.h:27
Seismic Drive Utilities class.
Definition: SDUtils.h:36
Defines operation BulkDelete Status.
Definition: Types.h:27