Skip to content

Commit

Permalink
feat: Added getFolderDetails function for raw folder details
Browse files Browse the repository at this point in the history
  • Loading branch information
batje committed Feb 4, 2019
1 parent 73e41d7 commit 7016b39
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 42 deletions.
44 changes: 28 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,20 @@ module against Cognos Analytics 11.0.7 or later, follow these steps:
- [listPublicFolders](#listpublicfolders)
- [listFolderById](#listfolderbyid)
- [Parameters](#parameters-2)
- [addFolder](#addfolder)
- [getFolderDetails](#getfolderdetails)
- [Parameters](#parameters-3)
- [deleteFolder](#deletefolder)
- [addFolder](#addfolder)
- [Parameters](#parameters-4)
- [uploadExtension](#uploadextension)
- [deleteFolder](#deletefolder)
- [Parameters](#parameters-5)
- [uploadExtension](#uploadextension)
- [Parameters](#parameters-6)
- [loggedin](#loggedin)
- [getCognos](#getcognos)
- [Parameters](#parameters-6)
- [CognosObject](#cognosobject)
- [Properties](#properties)
- [Parameters](#parameters-7)
- [NameSpace](#namespace)
- [Properties](#properties)
- [CognosObject](#cognosobject)
- [Properties](#properties-1)
- [cRequest](#crequest)
- [isStandardBrowserEnv](#isstandardbrowserenv)
Expand Down Expand Up @@ -174,11 +176,21 @@ listFolderById - Lists the folder content by id
#### Parameters

- `id` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Cognos Object id of the folder
- `pattern` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** = '_' Pattern like you would use when listing folders in your filesystem. eg. 'Sales_' (optional, default `'*'`)
- `types` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** = '['folder']' Types of Cognos objects to list. defaults to folders only. Other values could be 'report' (optional, default `['folder']`)
- `pattern` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** = '_' Pattern like you would use when listing folders in your filesystem. eg. 'Sales_' (optional, default `"*"`)
- `types` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** = '['folder']' Types of Cognos objects to list. defaults to folders only. Other values could be 'report' (optional, default `["folder"]`)

Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[CognosObject](#cognosobject)>** List of sub-folders

### getFolderDetails

getFolderDetails - Gets the raw Cognos details of a folder

#### Parameters

- `id` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** objectId

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Full object as returned by Cognos

### addFolder

addFolder - Creates a new folder
Expand Down Expand Up @@ -211,7 +223,7 @@ This function is only supported by Node.js. In the browser this function returns

- `filename` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Path to the .zip file
- `name` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name of the module (as found in the spec.json)
- `type` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** type of upload. Default is 'extensions', for themes use 'themes'. (optional, default `'extensions'`)
- `type` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** type of upload. Default is 'extensions', for themes use 'themes'. (optional, default `"extensions"`)

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** Promise that resolves to a string.

Expand All @@ -235,24 +247,24 @@ at any time.

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** a promise that will return the jCognos object

## CognosObject
## NameSpace

Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)

### Properties

- `id` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Cognos Object Id
- `name` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of object.
- `id` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The id of the namespace
- `value` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Displayname of the NameSpace
- `isDefault` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Set to true if this is the default namespace

## NameSpace
## CognosObject

Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)

### Properties

- `id` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The id of the namespace
- `value` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Displayname of the NameSpace
- `isDefault` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Set to true if this is the default namespace
- `id` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Cognos Object Id
- `name` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of object.

## cRequest

Expand Down
128 changes: 102 additions & 26 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ <h3 class='mb0 no-anchor'>jcognos</h3>
#listFolderById
</a></li>

<li><a
href='#cognosgetfolderdetails'
class='regular pre-open'>
#getFolderDetails
</a></li>

<li><a
href='#cognosaddfolder'
class='regular pre-open'>
Expand Down Expand Up @@ -159,19 +165,19 @@ <h3 class='mb0 no-anchor'>jcognos</h3>


<li><a
href='#cognosobject'
href='#namespace'
class="">
CognosObject
NameSpace

</a>

</li>


<li><a
href='#namespace'
href='#cognosobject'
class="">
NameSpace
CognosObject

</a>

Expand Down Expand Up @@ -1036,7 +1042,7 @@ <h3 class='fl m0' id='cognos'>
<div class='space-bottom0'>
<div>
<span class='code bold'>pattern</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>
= <code>&#39;*&#39;</code>)</code>
= <code>&quot;*&quot;</code>)</code>
= '
<em>' Pattern like you would use when listing folders in your filesystem. eg. 'Sales</em>
'
Expand All @@ -1048,7 +1054,7 @@ <h3 class='fl m0' id='cognos'>
<div class='space-bottom0'>
<div>
<span class='code bold'>types</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>
= <code>[&#39;folder&#39;]</code>)</code>
= <code>[&quot;folder&quot;]</code>)</code>
= '
['folder']
' Types of Cognos objects to list. defaults to folders only. Other values could be 'report'
Expand Down Expand Up @@ -1081,6 +1087,76 @@ <h3 class='fl m0' id='cognos'>



</section>

</div>
</div>

<div class='border-bottom' id='cognosgetfolderdetails'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>getFolderDetails(id)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>



<p>getFolderDetails - Gets the raw Cognos details of a folder</p>



<div class='pre p1 fill-light mt0'>getFolderDetails(id: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></div>












<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>

<div class='space-bottom0'>
<div>
<span class='code bold'>id</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
objectId

</div>

</div>

</div>






<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code>:
Full object as returned by Cognos














</section>

</div>
Expand Down Expand Up @@ -1309,7 +1385,7 @@ <h3 class='fl m0' id='cognos'>
<div class='space-bottom0'>
<div>
<span class='code bold'>type</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>
= <code>&#39;extensions&#39;</code>)</code>
= <code>&quot;extensions&quot;</code>)</code>
type of upload. Default is 'extensions', for themes use 'themes'.

</div>
Expand Down Expand Up @@ -1459,8 +1535,8 @@ <h3 class='fl m0' id='getcognos'>

<div class='clearfix'>

<h3 class='fl m0' id='cognosobject'>
CognosObject
<h3 class='fl m0' id='namespace'>
NameSpace
</h3>


Expand All @@ -1470,7 +1546,7 @@ <h3 class='fl m0' id='cognosobject'>



<div class='pre p1 fill-light mt0'>CognosObject</div>
<div class='pre p1 fill-light mt0'>NameSpace</div>


<p>
Expand All @@ -1495,14 +1571,21 @@ <h3 class='fl m0' id='cognosobject'>

<div class='space-bottom0'>
<span class='code bold'>id</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
: Cognos Object Id
: The id of the namespace


</div>

<div class='space-bottom0'>
<span class='code bold'>name</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
: Name of object.
<span class='code bold'>value</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
: Displayname of the NameSpace


</div>

<div class='space-bottom0'>
<span class='code bold'>isDefault</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a>)</code>
: Set to true if this is the default namespace


</div>
Expand Down Expand Up @@ -1530,8 +1613,8 @@ <h3 class='fl m0' id='cognosobject'>

<div class='clearfix'>

<h3 class='fl m0' id='namespace'>
NameSpace
<h3 class='fl m0' id='cognosobject'>
CognosObject
</h3>


Expand All @@ -1541,7 +1624,7 @@ <h3 class='fl m0' id='namespace'>



<div class='pre p1 fill-light mt0'>NameSpace</div>
<div class='pre p1 fill-light mt0'>CognosObject</div>


<p>
Expand All @@ -1566,21 +1649,14 @@ <h3 class='fl m0' id='namespace'>

<div class='space-bottom0'>
<span class='code bold'>id</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
: The id of the namespace


</div>

<div class='space-bottom0'>
<span class='code bold'>value</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
: Displayname of the NameSpace
: Cognos Object Id


</div>

<div class='space-bottom0'>
<span class='code bold'>isDefault</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a>)</code>
: Set to true if this is the default namespace
<span class='code bold'>name</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
: Name of object.


</div>
Expand Down
32 changes: 32 additions & 0 deletions src/Cognos.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,38 @@ class Cognos {
return result;
}

/**
* getFolderDetails - Gets the raw Cognos details of a folder
*
* @param {String} id objectId
* @return {Object} Full object as returned by Cognos
*/
getFolderDetails(id) {
var me = this;
var url =
'bi/v1/objects/' +
id +
'?fields=id,defaultName,owner.defaultName,ancestors,defaultDescription,modificationTime,creationTime,contact,type,disabled,hidden,name.locale,permissions,tenantID,searchPath,repositoryRules';
return me.requester
.get(url)
.then(function(details) {
me.log('Got Folder Details', details);
return details;
})
.catch(function(err) {
me.error('CognosRequest : Error in getFolderDetails', err);
me.handleError(err)
.then(function() {
me.log('We have been reset, getFolderDetails again');
me.resetting = false;
return me.getFolderDetails(id);
})
.catch(function() {
throw err;
});
});
}

/**
* addFolder - Creates a new folder
*
Expand Down

0 comments on commit 7016b39

Please sign in to comment.