cognos

package module
v0.0.0-...-0b2fc6e Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2019 License: AGPL-3.0 Imports: 15 Imported by: 2

README

see godoc.org/github.com/9072997/cognos

Documentation

Overview

This is for accessing The Arkansas Department of Education Cognos system. it might also work for other Cognos installations. It can list directories. and run/download reports (that have already been built) synchronously to CSV strings. It does not support anything other than default parameters, so save default parameters or build reports that don't have parameters. Basically everything panics on failure. I use a helper function called Try() to handle these panics (http://github.com/9072997/jgh). This library would not have been possible without the code generously open sourced by Scott Organ (https://github.com/scottorgan/cognosant).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CognosInstance

type CognosInstance struct {
	User       string
	Pass       string
	URL        string
	Namespace  string
	DSN        string
	RetryDelay uint
	RetryCount int
	// contains filtered or unexported fields
}

func MakeInstance

func MakeInstance(
	user, pass, url, namespace, dsn string,
	retryDelay uint,
	retryCount int,
	httpTimeout uint,
	concurrentRequests uint,
) (c CognosInstance)

MakeInstance creates a new cognos object. user is the user used to connect to Cognos (ex: APSCN\0401jpenn). This value also changes which "my folders" folder ~ points to. url is the base URL of the cognos server (ex: https://adecognos.arkansas.gov). namespace is the first thing you choose when signing in to Cognos. I don't totally know what dsn is, but mine is bentonvisms. If you open cognos in eschool and view source, you can see this value in the URL for the iframe. There is a diffrent one for eschool and e-finance. retryDelay is the number of seconds before a failed request will be retried. It is also the polling interval when waiting for a report to finish. retryCount is the number of times a failed request will be retried. A retryCount of -1 will retry forever. Polling unfinished reports is unaffected by this. httpTimeout is the number seconds before giving up on a Cognos HTTP request. concurrentRequests limits the maximum number of requests going at once.

func (CognosInstance) DownloadReportCSV

func (c CognosInstance) DownloadReportCSV(id string) string

DownloadReportCSV returns a string containing CSV data for a cognos report. This function triggers the execution of the report, and may take a while to return.

func (CognosInstance) FolderEntryFromPath

func (c CognosInstance) FolderEntryFromPath(path []string) FolderEntry

FolderEntryFromPath returns a folderEntry object representing whatever is at path. Path is a sloce of strings. The first string should be either "public" or "~" for public folders or my folders. Each string after that should represent the name of a folder. The last string may be the name of a report or a folder. BUG(jon): dosen't support "my folders" by username (only ~)

func (CognosInstance) LsFolder

func (c CognosInstance) LsFolder(id string) map[string]FolderEntry

LsFolder returnes a map of folder/report names to objects. Each object represents a folder entry. Each entry has a type (folder or report) and an ID

func (CognosInstance) Request

func (c CognosInstance) Request(method string, link string, reqBody string) (respBody string)

Request makes a HTTP GET request to the link (not including hostname) provided via the "link" parameter. The response body is returned as a string. Any errors (including a non-200 response) will cause this function to panic.

type FolderEntry

type FolderEntry struct {
	// compare this with the constants Folder or Type
	Type FolderEntryType `json:"type"`
	ID   string          `json:"id"`
}

FolderEntry represents either a folder or a report (anything that can be in a folder)

type FolderEntryType

type FolderEntryType uint
const (
	Folder FolderEntryType = iota
	Report FolderEntryType = iota
)

func (FolderEntryType) MarshalJSON

func (t FolderEntryType) MarshalJSON() ([]byte, error)

MarshalJSON marshals a field that is basically an enum. in case you want to convert directoryEntries to json

Notes

Bugs

  • searchKey is not escaped

  • dosen't support "my folders" by username (only ~)

  • This just panics on questionable characters. eventuially it would be nice to actually escape these.

  • this is unused

Jump to

Keyboard shortcuts

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