Introduction
You may be an OIC customer leveraging the File Server. You may also have use cases that require using the File Server REST API. If you're such a customer, read on!
Firstly, the File Server API docs are available here.
Always good to start there - now there are some subtle differences between usage of the OIC Integration Factory api and that for File Server.
Generate a Token
First Step is to generate a token - here I'm using Postman -
https://yourIDCS/oauth2/v1/token
As you can see, I use
x-www-form-encoded as the format.
grant_type is set to password
scope is set to the 2 OIC scopes you use with the Integration factory api.
username and password is that of my oic user.
Execute the POST request and you should get the token. If you get an unauthorized back, then check the IDCS app you are using - here is mine -
Validate IDCS App
Note, I've also checked
Resource owner.
As you can see, I've added this app to the
ServiceAdministrator role.
Now you should be able to generate your token.
Using the token in a File Server API Request
First api I invoke is -
I realise the documentation format is somewhat different to the OIC REST API docs for integration etc. But don't fret - the protocol, host and base path are analogue to the integration api.
https://design.integration.yourRegion.ocp.oraclecloud.com/ic/api/fileserver/v1/services/sftp/configuration?integrationInstance=yourOICinstance
I copy and paste in the token and execute the request -
So that's the sanity test done.
Now to creating a new folder...
Create a New Folder via the File Server API
Here's the Postman configuration -
{"createdDate": "01-01-2025",
"name": "myFolder",
"parent": "{{fsPath}}"}
The {{fsPath}} refers to an environment variable I created -
Response -
{
"guid": "a75885b1e5dd473c8b9834b82bcd19d9",
"path": "/home/users/niall.commiskey@oracle.com/myFolder",
"createDate": null,
"directories": [],
"files": [],
"links": [
{
"rel": "resource",
"href": "/ic/api/fileserver/v1/filesystem/root/home/users/niall.commiskey@oracle.com/myFolder"
},
{
"rel": "permission",
"href": "/ic/api/fileserver/v1/filesystem/directories/a75885b1e5dd473c8b9834b82bcd19d9/permissions"
}
]
}
I validate in OIC File Server UI -
Summa Summarum
The File Server factory api makes it easy to manage your file server environment. I'm certain those working more intensively with OIC File Server will find great use for it.
No comments:
Post a Comment