mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Cloud: Use separate files for Osdu and Sumo tokens.
This commit is contained in:
parent
8ddcbe7368
commit
3e2af38c90
@ -37,6 +37,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryDefines.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaOsduDefines.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaCloudDefines.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.h
|
||||
@ -81,6 +82,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSeismicDefines.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaOsduDefines.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaCloudDefines.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaFileDownloader.cpp
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "Cloud/RiaOsduConnector.h"
|
||||
#include "Cloud/RiaSumoConnector.h"
|
||||
#include "Cloud/RiaSumoDefines.h"
|
||||
#include "RiaOsduDefines.h"
|
||||
|
||||
#include "RiaArgumentParser.h"
|
||||
#include "RiaBaseDefs.h"
|
||||
@ -1714,7 +1715,7 @@ RiaOsduConnector* RiaApplication::makeOsduConnector()
|
||||
const unsigned int port = 35327;
|
||||
|
||||
m_osduConnector = new RiaOsduConnector( RiuMainWindow::instance(), server, dataPartitionId, authority, scopes, clientId, port );
|
||||
m_osduConnector->setTokenDataFilePath( RiaSumoDefines::tokenPath() );
|
||||
m_osduConnector->setTokenDataFilePath( RiaOsduDefines::tokenPath() );
|
||||
m_osduConnector->importTokenFromFile();
|
||||
|
||||
return m_osduConnector;
|
||||
@ -1735,7 +1736,6 @@ RiaSumoConnector* RiaApplication::makeSumoConnector()
|
||||
const unsigned int port = 53527;
|
||||
|
||||
m_sumoConnector = new RiaSumoConnector( RiuMainWindow::instance(), server, authority, scopes, clientId, port );
|
||||
|
||||
m_sumoConnector->setTokenDataFilePath( RiaSumoDefines::tokenPath() );
|
||||
m_sumoConnector->importTokenFromFile();
|
||||
}
|
||||
|
35
ApplicationLibCode/Application/RiaCloudDefines.cpp
Normal file
35
ApplicationLibCode/Application/RiaCloudDefines.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2024- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaCloudDefines.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaCloudDefines::contentTypeJson()
|
||||
{
|
||||
return "application/json";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaCloudDefines::contentTypeParquet()
|
||||
{
|
||||
return "application/x-parquet";
|
||||
}
|
27
ApplicationLibCode/Application/RiaCloudDefines.h
Normal file
27
ApplicationLibCode/Application/RiaCloudDefines.h
Normal file
@ -0,0 +1,27 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2024- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace RiaCloudDefines
|
||||
{
|
||||
QString contentTypeJson();
|
||||
QString contentTypeParquet();
|
||||
}; // namespace RiaCloudDefines
|
@ -18,10 +18,12 @@
|
||||
|
||||
#include "RiaOsduDefines.h"
|
||||
|
||||
#include <QDir>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaDefines::osduFieldKind()
|
||||
QString RiaOsduDefines::osduFieldKind()
|
||||
{
|
||||
return "osdu:wks:master-data--Field:1.0.0";
|
||||
}
|
||||
@ -29,7 +31,7 @@ QString RiaDefines::osduFieldKind()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaDefines::osduWellKind()
|
||||
QString RiaOsduDefines::osduWellKind()
|
||||
{
|
||||
return "osdu:wks:master-data--Well:1.*.*";
|
||||
}
|
||||
@ -37,7 +39,7 @@ QString RiaDefines::osduWellKind()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaDefines::osduWellboreKind()
|
||||
QString RiaOsduDefines::osduWellboreKind()
|
||||
{
|
||||
return "osdu:wks:master-data--Wellbore:1.*.*";
|
||||
}
|
||||
@ -45,7 +47,7 @@ QString RiaDefines::osduWellboreKind()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaDefines::osduWellboreTrajectoryKind()
|
||||
QString RiaOsduDefines::osduWellboreTrajectoryKind()
|
||||
{
|
||||
return "osdu:wks:work-product-component--WellboreTrajectory:1.*.*";
|
||||
}
|
||||
@ -53,7 +55,7 @@ QString RiaDefines::osduWellboreTrajectoryKind()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaDefines::osduWellLogKind()
|
||||
QString RiaOsduDefines::osduWellLogKind()
|
||||
{
|
||||
return "osdu:wks:work-product-component--WellLog:1.*.*";
|
||||
}
|
||||
@ -61,15 +63,8 @@ QString RiaDefines::osduWellLogKind()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaDefines::contentTypeJson()
|
||||
QString RiaOsduDefines::tokenPath()
|
||||
{
|
||||
return "application/json";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaDefines::contentTypeParquet()
|
||||
{
|
||||
return "application/x-parquet";
|
||||
QString homePath = QDir::homePath();
|
||||
return homePath + "/.resinsight/osdu_token.json";
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace RiaDefines
|
||||
namespace RiaOsduDefines
|
||||
{
|
||||
QString osduFieldKind();
|
||||
QString osduWellKind();
|
||||
@ -29,4 +29,7 @@ QString osduWellboreTrajectoryKind();
|
||||
QString osduWellLogKind();
|
||||
QString contentTypeJson();
|
||||
QString contentTypeParquet();
|
||||
}; // namespace RiaDefines
|
||||
|
||||
QString tokenPath();
|
||||
|
||||
}; // namespace RiaOsduDefines
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "RiaOsduConnector.h"
|
||||
#include "RiaCloudDefines.h"
|
||||
#include "RiaFileDownloader.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaOsduDefines.h"
|
||||
@ -86,7 +87,7 @@ void RiaOsduConnector::requestFieldsByName( const QString& fieldName )
|
||||
void RiaOsduConnector::requestFieldsByName( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldName )
|
||||
{
|
||||
std::map<QString, QString> params;
|
||||
params["kind"] = RiaDefines::osduFieldKind();
|
||||
params["kind"] = RiaOsduDefines::osduFieldKind();
|
||||
params["limit"] = "10000";
|
||||
params["query"] = "data.FieldName:" + fieldName;
|
||||
|
||||
@ -122,7 +123,7 @@ void RiaOsduConnector::requestWellsByFieldId( const QString& fieldId )
|
||||
void RiaOsduConnector::requestWellsByFieldId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldId )
|
||||
{
|
||||
std::map<QString, QString> params;
|
||||
params["kind"] = RiaDefines::osduWellKind();
|
||||
params["kind"] = RiaOsduDefines::osduWellKind();
|
||||
params["limit"] = "10000";
|
||||
params["query"] = QString( "nested(data.GeoContexts, (FieldID:\"%1\"))" ).arg( fieldId );
|
||||
|
||||
@ -158,7 +159,7 @@ void RiaOsduConnector::requestWellboresByWellId( const QString& wellId )
|
||||
void RiaOsduConnector::requestWellboresByWellId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& wellId )
|
||||
{
|
||||
std::map<QString, QString> params;
|
||||
params["kind"] = RiaDefines::osduWellboreKind();
|
||||
params["kind"] = RiaOsduDefines::osduWellboreKind();
|
||||
params["limit"] = "10000";
|
||||
params["query"] = "data.WellID: \"" + wellId + "\"";
|
||||
|
||||
@ -212,7 +213,7 @@ void RiaOsduConnector::requestWellLogsByWellboreId( const QString& server,
|
||||
const QString& wellboreId )
|
||||
{
|
||||
std::map<QString, QString> params;
|
||||
params["kind"] = RiaDefines::osduWellLogKind();
|
||||
params["kind"] = RiaOsduDefines::osduWellLogKind();
|
||||
params["limit"] = "10000";
|
||||
params["query"] = "data.WellboreID: \"" + wellboreId + "\"";
|
||||
|
||||
@ -251,7 +252,7 @@ void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& ser
|
||||
const QString& wellboreId )
|
||||
{
|
||||
std::map<QString, QString> params;
|
||||
params["kind"] = RiaDefines::osduWellboreTrajectoryKind();
|
||||
params["kind"] = RiaOsduDefines::osduWellboreTrajectoryKind();
|
||||
params["limit"] = "10000";
|
||||
params["query"] = "data.WellboreID: \"" + wellboreId + "\"";
|
||||
|
||||
@ -316,7 +317,7 @@ QNetworkReply* RiaOsduConnector::makeSearchRequest( const std::map<QString, QStr
|
||||
QNetworkRequest m_networkRequest;
|
||||
m_networkRequest.setUrl( QUrl( constructSearchUrl( server ) ) );
|
||||
|
||||
addStandardHeader( m_networkRequest, token, dataPartitionId, RiaDefines::contentTypeJson() );
|
||||
addStandardHeader( m_networkRequest, token, dataPartitionId, RiaCloudDefines::contentTypeJson() );
|
||||
|
||||
QJsonObject obj;
|
||||
for ( auto [key, value] : parameters )
|
||||
@ -755,7 +756,7 @@ void RiaOsduConnector::requestParquetData( const QString& url, const QString& da
|
||||
{
|
||||
RiaLogging::info( "Requesting download of parquet from: " + url );
|
||||
|
||||
auto reply = makeDownloadRequest( url, dataPartitionId, token, RiaDefines::contentTypeParquet() );
|
||||
auto reply = makeDownloadRequest( url, dataPartitionId, token, RiaCloudDefines::contentTypeParquet() );
|
||||
|
||||
connect( reply,
|
||||
&QNetworkReply::finished,
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "RiaSumoConnector.h"
|
||||
|
||||
#include "RiaCloudDefines.h"
|
||||
#include "RiaConnectorTools.h"
|
||||
#include "RiaFileDownloader.h"
|
||||
#include "RiaLogging.h"
|
||||
@ -95,7 +96,7 @@ void RiaSumoConnector::requestCasesForField( const QString& fieldName )
|
||||
QNetworkRequest m_networkRequest;
|
||||
m_networkRequest.setUrl( QUrl( constructSearchUrl( m_server ) ) );
|
||||
|
||||
addStandardHeader( m_networkRequest, token(), RiaDefines::contentTypeJson() );
|
||||
addStandardHeader( m_networkRequest, token(), RiaCloudDefines::contentTypeJson() );
|
||||
|
||||
QString payloadTemplate = R"(
|
||||
{
|
||||
@ -156,7 +157,7 @@ void RiaSumoConnector::requestAssets()
|
||||
QNetworkRequest m_networkRequest;
|
||||
m_networkRequest.setUrl( QUrl( m_server + "/api/v1/userpermissions" ) );
|
||||
|
||||
addStandardHeader( m_networkRequest, token(), RiaDefines::contentTypeJson() );
|
||||
addStandardHeader( m_networkRequest, token(), RiaCloudDefines::contentTypeJson() );
|
||||
|
||||
auto reply = m_networkAccessManager->get( m_networkRequest );
|
||||
|
||||
@ -218,7 +219,7 @@ void RiaSumoConnector::requestEnsembleByCasesId( const SumoCaseId& caseId )
|
||||
QNetworkRequest m_networkRequest;
|
||||
m_networkRequest.setUrl( QUrl( m_server + "/api/v1/search" ) );
|
||||
|
||||
addStandardHeader( m_networkRequest, token(), RiaDefines::contentTypeJson() );
|
||||
addStandardHeader( m_networkRequest, token(), RiaCloudDefines::contentTypeJson() );
|
||||
|
||||
auto payload = payloadTemplate.arg( caseId.get() );
|
||||
auto reply = m_networkAccessManager->post( m_networkRequest, payload.toUtf8() );
|
||||
@ -291,7 +292,7 @@ void RiaSumoConnector::requestVectorNamesForEnsemble( const SumoCaseId& caseId,
|
||||
QNetworkRequest m_networkRequest;
|
||||
m_networkRequest.setUrl( QUrl( m_server + "/api/v1/search" ) );
|
||||
|
||||
addStandardHeader( m_networkRequest, token(), RiaDefines::contentTypeJson() );
|
||||
addStandardHeader( m_networkRequest, token(), RiaCloudDefines::contentTypeJson() );
|
||||
|
||||
auto payload = payloadTemplate.arg( caseId.get() ).arg( ensembleName );
|
||||
auto reply = m_networkAccessManager->post( m_networkRequest, payload.toUtf8() );
|
||||
@ -360,7 +361,7 @@ void RiaSumoConnector::requestRealizationIdsForEnsemble( const SumoCaseId& caseI
|
||||
QNetworkRequest m_networkRequest;
|
||||
m_networkRequest.setUrl( QUrl( m_server + "/api/v1/search" ) );
|
||||
|
||||
addStandardHeader( m_networkRequest, token(), RiaDefines::contentTypeJson() );
|
||||
addStandardHeader( m_networkRequest, token(), RiaCloudDefines::contentTypeJson() );
|
||||
|
||||
auto payload = payloadTemplate.arg( caseId.get() ).arg( ensembleName );
|
||||
auto reply = m_networkAccessManager->post( m_networkRequest, payload.toUtf8() );
|
||||
@ -423,7 +424,7 @@ void RiaSumoConnector::requestBlobIdForEnsemble( const SumoCaseId& caseId, const
|
||||
QNetworkRequest m_networkRequest;
|
||||
m_networkRequest.setUrl( QUrl( m_server + "/api/v1/search" ) );
|
||||
|
||||
addStandardHeader( m_networkRequest, token(), RiaDefines::contentTypeJson() );
|
||||
addStandardHeader( m_networkRequest, token(), RiaCloudDefines::contentTypeJson() );
|
||||
|
||||
auto payload = payloadTemplate.arg( caseId.get() ).arg( ensembleName ).arg( vectorName );
|
||||
auto reply = m_networkAccessManager->post( m_networkRequest, payload.toUtf8() );
|
||||
@ -469,7 +470,7 @@ void RiaSumoConnector::requestBlobDownload( const QString& blobId )
|
||||
// did not work. Use ManualRedirectPolicy instead, and inspect the reply for the redirection target.
|
||||
networkRequest.setAttribute( QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::ManualRedirectPolicy );
|
||||
|
||||
addStandardHeader( networkRequest, token(), RiaDefines::contentTypeJson() );
|
||||
addStandardHeader( networkRequest, token(), RiaCloudDefines::contentTypeJson() );
|
||||
|
||||
auto reply = m_networkAccessManager->get( networkRequest );
|
||||
|
||||
@ -592,7 +593,7 @@ QNetworkReply* RiaSumoConnector::makeRequest( const std::map<QString, QString>&
|
||||
QNetworkRequest m_networkRequest;
|
||||
m_networkRequest.setUrl( QUrl( constructSearchUrl( server ) ) );
|
||||
|
||||
addStandardHeader( m_networkRequest, token, RiaDefines::contentTypeJson() );
|
||||
addStandardHeader( m_networkRequest, token, RiaCloudDefines::contentTypeJson() );
|
||||
|
||||
QJsonObject obj;
|
||||
for ( auto [key, value] : parameters )
|
||||
@ -841,7 +842,7 @@ void RiaSumoConnector::requestParquetData( const QString& url, const QString& to
|
||||
{
|
||||
RiaLogging::info( "Requesting download of parquet from: " + url );
|
||||
|
||||
auto reply = makeDownloadRequest( url, token, RiaDefines::contentTypeJson() );
|
||||
auto reply = makeDownloadRequest( url, token, RiaCloudDefines::contentTypeJson() );
|
||||
connect( reply,
|
||||
&QNetworkReply::finished,
|
||||
[this, reply, url]()
|
||||
|
Loading…
Reference in New Issue
Block a user