Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titleStart with a copy of new Custom component

Let’s use a new Custom component and name it ‘Confluence adapter’

Make a copy and edit…

image-20240319-152408.pngImage Added
Expand
titleImport the SHELL library and associate it with a new repo

Let’s say git@bitbucket.org:interfaceware/atlassian

Expand
titleRename the folder and all the files in it to a new prefix

For instance:

Expand
Create a new git repo for your new Library
title

Use ‘View Remote’ for the now named ATTL library

image-20240319-145410.pngImage Removed

… and specify new REPOSITORY name for this Library to be associated with

image-20240319-145629.pngImage Removed
Expand
titleSearch and replace SHELL for ATTL in the project

This gets all the prefixes consistent.

Expand
titleMake sure the ATTLclient function gets the parameters needed to authenticate
Code Block
languagelua
function ATTLclient(T)
   local S= {}
   setmetatable(S, MT)
   S.key = T.key
   return S
end

So in the case of Atlassian we need:

  • user - I.e. fred.smith@acmesmith@interfaceware.com

  • space - i.e. ABC for a Confluence space that has this ID

  • key - A unique personal API key for a confluence user

  • organization - to construct base URL to our Confluence space, e.g. https://acme.atalassian.net

This adheres with Naming convention for table parameters in Iguana.

These should just be passed through in the table arguments. So the code becomes:

Code Block
languagelua
function ATTLclient(T)
   local S= {}
   setmetatable(S, MT)
   S.key           = T.key
   S.space         = T.space
   S.user          = T.user
   S.organization  = T.organization
   return S
end

...

Expand
titleUpdate Client Constructor

Append to Client’s meta table the three newly added methods

Image Removed

and the ‘space_id’ variable declaration

Code Block
local MT={}

MT.__index = {}
MT.__index.descendants     = require 'ATTL.ATTLdescendants'
MT.__index.getSpaceId      = require 'ATTL.ATTLgetSpaceId'
MT.__index.getDescendants  = require 'ATTL.ATTLgetDescendants'

help.map{dir='ATTL/help',methods=MT.__index}

function ATTLclient(T)
   local S= {}
   setmetatable(S, MT)
   S.key           = T.key
   S.space         = T.space
   S.user          = T.user
   S.organization  = T.organization
   S.space_id      = T.space_id
   return S
end
Expand
titleNot to forget the Help files

Add Help files to explain what parameters your custom methods expect. Other users will appreciate this!Take opportunity to obsolete the ATTLclient.help file and to publish this information as client.help file in the ‘help’ folder, along with the rest of help files.

image-20240319-153543.pngImage Added
Expand
titleTime to put all of this to good work.

Let’s create a simple main.lua file

Code Block
require "ATTL.ATTLclient"

A = ATTLclient{
   key          = component.fields().key,
   space        = 'EC',
   user         = 'levfred.blum@interfacewaresmith@interfaceware.com',
   organization = 'interfaceware'
} 

function main(Data)
   A:getSpaceId() 
   local count = 2 
   A:descendants{count = count, live = true}
end
Expand
titleHow does this main.lua works?

Right after declaration of Client instance and passing the parameters to it, we discover the Confluence Space ID. This value couldn’t be known without running this API call.

Next we prepare for paginated API call and require only 2 calls to be executed by setting ‘count’ variable to number 2. This will save the time while testing.

And finally, we request from API and get a to return the listing of descendants for 50 pages.

Image Removedimage-20240319-154423.pngImage Added
Expand
titleShare a little of 'what is next'?

So, we can query Atlassian API for Confluence! What it is good for? We can query documents, we can edit documents, we can modify/export/add/delete content in any manner we imagine. The complete documentation for this API is available here.

Just create more API methods and more Custom methods.

Custom methods are very helpful to keep the API methods true to vendors API documentation. Custom methods will help to create your specific parameters combination, and to massage the responses. Custom methods are the interface, between your code , to clean and true API methods.