cloud

package
v0.0.0-...-0bfa77c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AzureClientIdEnvName = "AzureClientId"

globals pointing to enviroinment variables to look for

View Source
var AzureClientSecretEnvName = "AzureClientSecret"
View Source
var AzureFileDownloadUrlEnvName = "AzureFileDownloadUrl"
View Source
var AzureGraphUrlEnvName = "AzureGraphUrl"
View Source
var AzureResourceIdEnvName = "AzureResourceId"
View Source
var AzureSubscriptionKeyEnvName = "AzureSubscriptionKey"
View Source
var AzureTokenUrlEnvName = "AzureTokenUrl"
View Source
var MaxNumberOfDaysPeriod = 91.0 //controls the number of days that can be queried for using the period functionality
View Source
var MaxRollDays = 30 //control the max number of days that you can roll back in the download setup

Functions

func Authenticate

func Authenticate() (string, error)

func BuildOutputPathForReportType

func BuildOutputPathForReportType(fObj FileObject, filePrefix, outputFolder, format string) []string

BuildOutputPathForReportType will build the output folder path based on the report type DDRML data will be stored in outputFolder + name of wellbore and then the actual file the function will return an array of paths based on the source objects as especially ddrml files can contain several wellbores

func BuildQueryForAssetUsingCreated

func BuildQueryForAssetUsingCreated(fQuery FileQuery) ([]byte, error)

BuildQueryForAssetUsingCreated builds a qraphql query for file using created to/from date if the report type is either ddrml or dpr20 and the format is pdf it will ask for xml files instead as the minio storage just stores xml files for these report types and the pdf report is generated on the fly.

func BuildQueryForAssetUsingPeriod

func BuildQueryForAssetUsingPeriod(fQuery FileQuery) ([]byte, error)

BuildQueryForAssetUsingPeriod builds a qraphql query for file using period to/from date if the report type is either ddrml or dpr20 and the format is pdf it will ask for xml files instead as the minio storage just stores xml files for these report types and the pdf report is generated on the fly.

func CreateUUID

func CreateUUID() string

func DaysBetween

func DaysBetween(startDate, endDate string) (float64, error)

DaysBetween will check the numder of days between startdate and enddate where the dates are in the format YYYY-MM-DD e.g. 2019-03-28

func DownloadFile

func DownloadFile(fileReference, fileURL, token, subscriptionKey, format string) ([]byte, error)

DownloadFile downloads a single file using the given fileReference id, fileURL for Azure, token from oauth2, subscription key for service and format to download (pdf or xml)

func DownloadFiles

func DownloadFiles(files []FileObject, fileURL, token, subscriptionKey, format,
	outputFolder, filePrefix string, addTimeStampInName bool) []error

DownloadFiles downloads a set of files from a array of fileobjects, it will call download file function for each entry and dowload the data to the outputfolder, will return an array of possible errors assetName will be used to prefix the files addTimeStampInName will add a unix timestamp to the outputfile name identifying when the file was downloaded

func DownloadFilesToZip

func DownloadFilesToZip(fileReferences []FileObject, fileURL, token, subscriptionKey, format string) ([]byte, error)

DownloadFilesToZip downloads a set of files using the given array of fileReference id fileURL -> to download for from Azure: token -> recieved from oauth2 subscription key -> to use API service format -> the format to download (pdf or xml)

func FileOrFolderExists

func FileOrFolderExists(path string) bool

func GenerateFileName

func GenerateFileName(fObj FileObject, filePrefix, format string) string

GenerateFileName builds a filename based on the incoming criteria

func MapReportType

func MapReportType(reportType int) string

func ProcessAndRunDownload

func ProcessAndRunDownload(downloadConfig CloudDownload) []error

ProcessAndRunDownload will process and query for a set of files as defined in the download config any errors will be tracked on a file basis and returned

func RunQueryAndDownloadFiles

func RunQueryAndDownloadFiles(fQuery FileQuery, token, subscriptionKey, graphQLUrl,
	fileDownloadUrl string) error

RunQueryAndDownloadFiles will take an filequery object and run a graphql query for the specified files and using the file result it will try to download each file locally using the filedownloadurl and the file reference

func SafeEncodeNameForWinFiles

func SafeEncodeNameForWinFiles(name string) string

func StringRFC3339ToTime

func StringRFC3339ToTime(timeStamp string) (time.Time, error)

StringRFC3339ToTime will take a RFC3339 formatted string, e.g. 2005-01-05T21:59:59.999Z and convert it to a time object

func TimeToStr

func TimeToStr(timeObj time.Time, format string) string

func VerifyCloudDownloadConfig

func VerifyCloudDownloadConfig(downloadConfig CloudDownload) error

VerifyCloudDownloadConfig will check the configuration data for errors

Types

type AuthConfig

type AuthConfig struct {
	ClientID        string
	ClientSecret    string
	TokenURL        string
	ResourceID      string
	SubScriptionKey string
	Token           string
}

type CloudCommonConfig

type CloudCommonConfig struct {
	XMLName          xml.Name `xml:"common"`
	Format           string   `xml:"format"`
	OutputFolder     string   `xml:"outputFolder"`
	FileOutputPrefix string   `xml:"fileOutputPrefix"`
}

type CloudConfig

type CloudConfig struct {
	ClientId        string `xml:"clientId"`
	ClientSecret    string `xml:"clientSecret"`
	TokenURL        string `xml:"tokenUrl"`
	ResourceId      string `xml:"resourceId"`
	FileDownloadUrl string `xml:"fileDownloadUrl"`
	SubscriptionKey string `xml:"subscriptionKey"`
	GraphURL        string `xml:"graphUrl"`
}

type CloudDDRMLConfig

type CloudDDRMLConfig struct {
	DateFrom        string `xml:"dateFrom"`
	DateTo          string `xml:"dateTo"`
	RollDays        int    `xml:"rollDays"`
	UseUploadedFrom bool   `xml:"useUploadedFrom"`
	LogFile         string `xml:"logFile"`
	Common          CloudCommonConfig
}

type CloudDownload

type CloudDownload struct {
	XMLName     xml.Name                `xml:"subsurface"`
	CloudConfig CloudConfig             `xml:"config"`
	DPRS        []CloudProductionConfig `xml:"dpr"`
	MPRGovs     []CloudProductionConfig `xml:"mprmlGov"`
	MPRPartners []CloudProductionConfig `xml:"mprmlPartner"`
	DDRMLS      []CloudDDRMLConfig      `xml:"ddrml"`
}

func CloudConfigArrayToStruct

func CloudConfigArrayToStruct(data []byte) (CloudDownload, error)

type CloudProductionConfig

type CloudProductionConfig struct {
	FieldName       string `xml:"fieldName"`
	DateFrom        string `xml:"dateFrom"`
	DateTo          string `xml:"dateTo"`
	RollDays        int    `xml:"rollDays"`
	RollMonths      int    `xml:"rollMonths"`
	UseUploadedFrom bool   `xml:"useUploadedFrom"`
	LogFile         string `xml:"logFile"`
	Common          CloudCommonConfig
}

type DataErrors

type DataErrors struct {
	Message string `json:"message"`
}

type DataObject

type DataObject struct {
	Files  []FileObject `json:"files"`
	Errors []DataErrors `json:"errors"`
}

func RunGraphQueryForFiles

func RunGraphQueryForFiles(token, url, subscriptionKey string, query []byte) (DataObject, interface{}, error)

type DataSource

type DataSource struct {
	Kind         string `json:"kind"`
	Name         string `json:"name"`
	NamingSystem string `json:"namingSystem"`
}

type FileGraphResult

type FileGraphResult struct {
	Data DataObject `json:"data"`
}

type FileMetaData

type FileMetaData struct {
	FileType     string `json:"fileType"`
	PeriodEnd    string `json:"periodEnd"`
	PeriodStart  string `json:"periodStart"`
	ReportId     string `json:"reportId"`
	ReportStatus string `json:"reportStatus"`
}

type FileObject

type FileObject struct {
	FileName      string       `json:"fileName"`
	FileReference string       `json:"fileReferenceId"`
	Created       string       `json:"created"`
	MetaData      FileMetaData `json:"metadata"`
	ReportType    int          `json:"reportType"`
	Sources       []DataSource `json:"sources"`
}

type FileQuery

type FileQuery struct {
	TimeFrom        string
	TimeTo          string
	Field           string
	FileType        string
	ReportType      string
	UseUploadedFrom bool
	OutputLocation  string
	OutputPrefix    string
}

type FileQueryConfig

type FileQueryConfig struct {
	AuthCnfg        AuthConfig
	GraphURL        string
	FileDownloadUrl string
	Queries         []FileQuery
}

type GraphQuery

type GraphQuery struct {
	Query         string `json:"query"`
	OperationName string `json:"operationName,omitempty"`
	Variables     string `json:"variables,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL