├── client-samples ├── README.md ├── mail │ ├── nodejs │ │ ├── quotatest.js │ │ ├── sendmailtest.js │ │ ├── messagelisttest.js │ │ └── README.md │ └── java │ │ ├── client │ │ └── mail │ │ │ └── test │ │ │ ├── QuotaTest.java │ │ │ ├── MessageListTest.java │ │ │ ├── DelegateTest.java │ │ │ ├── MessageTest.java │ │ │ └── MailFolderTest.java │ │ └── README.md ├── freebusy │ ├── nodejs │ │ ├── busytimetest.js │ │ ├── freeroomstest.js │ │ └── README.md │ └── java │ │ ├── client │ │ └── freebusy │ │ │ └── test │ │ │ ├── BusyTimeTest.java │ │ │ ├── FreeRoomsTest.java │ │ │ └── SitesTest.java │ │ └── README.md ├── data │ ├── nodejs │ │ ├── viewdesigntest.js │ │ ├── viewentrytest.js │ │ ├── searchtest.js │ │ ├── documenttest.js │ │ └── README.md │ └── java │ │ ├── client │ │ └── data │ │ │ └── test │ │ │ ├── DatabaseListTest.java │ │ │ ├── DocumentListTest.java │ │ │ └── ViewDesignTest.java │ │ └── README.md └── calendar │ ├── nodejs │ ├── noticetest.js │ └── README.md │ └── java │ ├── client │ └── calendar │ │ └── test │ │ ├── EventListTest.java │ │ ├── EventTest.java │ │ ├── NoticeTest.java │ │ └── MeetingTest.java │ └── README.md ├── directory.yaml ├── README.md └── freebusy.yaml /client-samples/README.md: -------------------------------------------------------------------------------- 1 | 15 | 16 | # IBM Domino Access Services Client Samples 17 | Sample code showing use of Domino Access Services (DAS) with Swagger 18 | generated client code. 19 | 20 | ### Calendar API sample code 21 | 22 | These samples demonstrate how to use the Domino calendar API. They 23 | require client code generated from **calendar.yaml**. See the detailed 24 | instructions for: 25 | 26 | - [Java samples](calendar/java) demonstrating calendar event and notice 27 | operations. The calendar event samples include operations on appointments, 28 | meetings and recurring events. 29 | - [Node.js samples](calendar/nodejs) demonstrating calendar notice 30 | operations. 31 | 32 | ### Freebusy API sample code 33 | 34 | These samples demonstrate how to use the Domino freebusy API. They 35 | require client code generated from **freebusy.yaml**. See the detailed 36 | instructions for: 37 | 38 | - [Java samples](freebusy/java) demonstrating requests for busy time and 39 | free rooms. 40 | - [Node.js samples](freebusy/nodejs) demonstrating requests for busy time 41 | and free rooms. 42 | 43 | ### Mail API sample code 44 | 45 | These samples demonstrate how to use the Domino mail API. They 46 | require client code generated from **mail.yaml**. See the detailed 47 | instructions for: 48 | 49 | - [Java samples](mail/java) demonstrating message, quota and delegation 50 | operations. The message operations include sending, drafting, reading 51 | and deleting messages. 52 | - [Node.js samples](mail/nodejs) demonstrating message and quota 53 | operations. 54 | 55 | ### Data API sample code 56 | 57 | These samples demonstrate how to use the Domino data API. They 58 | require client code generated from **data.yaml**. See the detailed 59 | instructions for: 60 | 61 | - [Java samples](data/java) demonstrating document, view and database operations. 62 | - [Node.js samples](data/nodejs) demonstrating document and view operations. 63 | 64 | -------------------------------------------------------------------------------- /client-samples/mail/nodejs/quotatest.js: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | // IMPORTANT: Change the required package name if necessary. 18 | 19 | var api = require('ibm_domino_mail_api'); 20 | 21 | // IMPORTANT: Change these values to match your test environment: 22 | // 23 | // - basePath is the base URL for your Domino server. 24 | // The mail service MUST be installed and enabled 25 | // on the server. Be sure to change the protocol to 26 | // http if your server doesn't support https. 27 | // 28 | // - username is the name of a user who has access to a 29 | // mail file on your Domino server 30 | // 31 | // - password is the user's password 32 | // 33 | // - folder is the mail file folder name relative to the Domino 34 | // data directory. Use '.' if the mail file is in the data 35 | // directory itself. 36 | // 37 | // - database is the mail file name. 38 | // 39 | var basePath = 'http://yourserver.yourorg.com'; 40 | var username = 'First Last'; 41 | var password = 'password'; 42 | var folder = 'mail'; 43 | var database = 'database.nsf'; 44 | 45 | /* Callback for quota request */ 46 | 47 | var callback = function(error, data, response) { 48 | if (error) { 49 | console.error(error); 50 | } 51 | else { 52 | if ( data != null ) { 53 | console.log('Quota request succeeded. Response follows ...'); 54 | 55 | var enabled = false; 56 | if ( data.enabled != undefined ) { 57 | enabled = data.enabled; 58 | } 59 | 60 | console.log(' enabled: ' + enabled); 61 | console.log(' actualSize: ' + data.actualSize); 62 | console.log(' usedSize: ' + data.usedSize); 63 | 64 | if ( enabled ) { 65 | console.log(' quotaSize: ' + data.quotaSize); 66 | console.log(' warningSize: ' + data.warningSize); 67 | } 68 | } 69 | else { 70 | console.log('Send mail request succeeded, but response does not contain a Location header.'); 71 | } 72 | } 73 | }; 74 | 75 | /* Start of main routine */ 76 | 77 | // Get the API instance and set the base path of 78 | // the target Domino server 79 | 80 | var quotaApi = new api.QuotaApi(); 81 | quotaApi.apiClient.basePath = basePath; 82 | 83 | // Set user name and password 84 | 85 | var basic = quotaApi.apiClient.authentications['basic']; 86 | basic.username = username; 87 | basic.password = password; 88 | 89 | // Send the request 90 | 91 | console.log('Reading quota from ' + database + ' ...'); 92 | quotaApi.folderDatabaseApiMailQuotaGet(folder, database, callback); 93 | -------------------------------------------------------------------------------- /client-samples/freebusy/nodejs/busytimetest.js: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | // IMPORTANT: Change the required package name if necessary. 18 | 19 | var api = require('ibm_domino_freebusy_api'); 20 | 21 | // IMPORTANT: Change these values to match your test environment: 22 | // 23 | // - basePath is the base URL for your Domino server. 24 | // The freebusy service MUST be installed and enabled 25 | // on the server. Be sure to change the protocol to 26 | // http if your sever doesn't support https. 27 | // 28 | // - username is the name of a user who has access to your 29 | // Domino server 30 | // 31 | // - password is the user's password 32 | // 33 | // - lookupName is the email address of a VALID user. Or you 34 | // can specify the lookup name on the command line. 35 | // 36 | // - btOpts.days is number of days of busy time data to return. 37 | 38 | var basePath = "https://yourserver.yourorg.com"; 39 | var username = "First Last"; 40 | var password = "password"; 41 | var lookupName = "user@yourorg.com"; 42 | var btOpts = { 43 | 'days': 7 44 | }; 45 | 46 | /* Callback for busytime request */ 47 | 48 | var btCallback = function(error, data, response) { 49 | if (error) { 50 | console.error(error); 51 | } 52 | else { 53 | if ( data.hasOwnProperty('busyTimes') ) { 54 | console.log('Busytime API called successfully. Response follows ...\n'); 55 | for ( var i = 0; i < data.busyTimes.length; i++ ) { 56 | console.log('start: ' + data.busyTimes[i].start.date + 'T' + data.busyTimes[i].start.time + 57 | '; end: ' + data.busyTimes[i].end.date + 'T' + data.busyTimes[i].end.time 58 | ); 59 | } 60 | } 61 | else { 62 | console.log('Busytime API called successfully, but response does not contain busytime data.'); 63 | } 64 | } 65 | }; 66 | 67 | /* Start of main routine */ 68 | 69 | // Parse command line arguments 70 | 71 | process.argv.forEach(function (val, index, array) { 72 | if ( index > 1 ) { 73 | lookupName = val; 74 | } 75 | }); 76 | 77 | // Get the API instance and set the base path of 78 | // the target Domino server 79 | 80 | var busytime = new api.BusytimeApi(); 81 | busytime.apiClient.basePath = basePath; 82 | 83 | // Set user name and password 84 | 85 | var basic = busytime.apiClient.authentications['basic']; 86 | basic.username = username; 87 | basic.password = password; 88 | 89 | // Send the request 90 | 91 | console.log('Requesting busytime for ' + lookupName + ' ...'); 92 | busytime.apiFreebusyBusytimeGet(lookupName, btOpts, btCallback); 93 | -------------------------------------------------------------------------------- /client-samples/data/nodejs/viewdesigntest.js: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | // IMPORTANT: Change the required package name if necessary. 18 | 19 | var api = require('ibm_domino_data_api'); 20 | 21 | // IMPORTANT: Change these values to match your test environment: 22 | // 23 | // - basePath is the base URL for your Domino server. 24 | // The data service MUST be installed and enabled 25 | // on the server. Be sure to change the protocol to 26 | // http if your server doesn't support https. 27 | // 28 | // - username is the name of a user who has access to your 29 | // Domino server 30 | // 31 | // - password is the user's password 32 | // 33 | // - folder is the database folder name relative to the Domino 34 | // data directory. Use '.' if the database is in the data 35 | // directory itself. 36 | // 37 | // - database is the database file name. Use 'XPagesExt.nsf' 38 | // if your server has a copy of the XPages Extension Library 39 | // demo database. 40 | // 41 | // - viewName is the name of a view in the database. 42 | // The Domino data service must be enabled for this view. 43 | 44 | var basePath = 'https://yourserver.yourorg.com'; 45 | var username = 'First Last'; 46 | var password = 'password'; 47 | var folder = '.'; 48 | var database = 'XPagesExt.nsf'; 49 | var viewName = 'AllTypes'; 50 | var opts = { 51 | }; 52 | 53 | /* Callback for view design request */ 54 | 55 | var callback = function(error, data, response) { 56 | if (error) { 57 | console.error(error); 58 | } 59 | else { 60 | debugger; 61 | if ( data.length > 0 ) { 62 | console.log('View design API called successfully. Response follows ...\n'); 63 | for ( var i = 0; i < data.length; i++ ) { 64 | console.log('Column ' + i); 65 | console.log(' name: ' + data[i]['@name']); 66 | console.log(' title: ' + data[i]['@title']); 67 | console.log(' width: ' + data[i]['@width']); 68 | console.log(' hidden: ' + data[i]['@hidden']); 69 | console.log(''); 70 | } 71 | } 72 | else { 73 | console.log('View design API called successfully, but response does not contain a view design.'); 74 | } 75 | } 76 | }; 77 | 78 | /* Start of main routine */ 79 | 80 | // Get the API instance and set the base path of 81 | // the target Domino server 82 | 83 | var designApi = new api.ViewDesignApi(); 84 | designApi.apiClient.basePath = basePath; 85 | 86 | // Set user name and password 87 | 88 | var basic = designApi.apiClient.authentications['basic']; 89 | basic.username = username; 90 | basic.password = password; 91 | 92 | // Send the request 93 | 94 | console.log('Requesting view design from ' + viewName + ' in database ' + database + ' ...'); 95 | designApi.folderDatabaseApiDataCollectionsNameViewNameDesignGet(folder, database, viewName, callback); 96 | -------------------------------------------------------------------------------- /client-samples/data/nodejs/viewentrytest.js: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | // IMPORTANT: Change the required package name if necessary. 18 | 19 | var api = require('ibm_domino_data_api'); 20 | 21 | // IMPORTANT: Change these values to match your test environment: 22 | // 23 | // - basePath is the base URL for your Domino server. 24 | // The data service MUST be installed and enabled 25 | // on the server. Be sure to change the protocol to 26 | // http if your server doesn't support https. 27 | // 28 | // - username is the name of a user who has access to your 29 | // Domino server 30 | // 31 | // - password is the user's password 32 | // 33 | // - folder is the database folder name relative to the Domino 34 | // data directory. Use '.' if the database is in the data 35 | // directory itself. 36 | // 37 | // - database is the database file name. Use 'XPagesExt.nsf' 38 | // if your server has a copy of the XPages Extension Library 39 | // demo database. 40 | // 41 | // - viewName is the name of a view in the database. 42 | // The Domino data service must be enabled for this view. 43 | 44 | var basePath = 'https://yourserver.yourorg.com'; 45 | var username = 'First Last'; 46 | var password = 'password'; 47 | var folder = '.'; 48 | var database = 'XPagesExt.nsf'; 49 | var viewName = 'AllTypes'; 50 | var opts = { 51 | }; 52 | 53 | /* Callback for view entries request */ 54 | 55 | var callback = function(error, data, response) { 56 | if (error) { 57 | console.error(error); 58 | } 59 | else { 60 | debugger; 61 | if ( data.length > 0 ) { 62 | console.log('View entry list API called successfully. Response follows ...\n'); 63 | for ( var i = 0; i < data.length; i++ ) { 64 | console.log('Entry ' + i); 65 | console.log(' entryid: ' + data[i]['@entryid']); 66 | console.log(' unid: ' + data[i]['@unid']); 67 | console.log(' form: ' + data[i]['@form']); 68 | console.log(' fldText: ' + data[i].fldText); 69 | console.log(' fldNumber: ' + data[i].fldNumber); 70 | console.log(''); 71 | } 72 | } 73 | else { 74 | console.log('View entry list API called successfully, but response does not contain view entries.'); 75 | } 76 | } 77 | }; 78 | 79 | /* Start of main routine */ 80 | 81 | // Get the API instance and set the base path of 82 | // the target Domino server 83 | 84 | var entryListApi = new api.ViewEntryListApi(); 85 | entryListApi.apiClient.basePath = basePath; 86 | 87 | // Set user name and password 88 | 89 | var basic = entryListApi.apiClient.authentications['basic']; 90 | basic.username = username; 91 | basic.password = password; 92 | 93 | // Send the request 94 | 95 | console.log('Requesting view entries from ' + viewName + ' in database ' + database + ' ...'); 96 | entryListApi.folderDatabaseApiDataCollectionsNameViewNameGet(folder, database, viewName, opts, callback); 97 | -------------------------------------------------------------------------------- /client-samples/data/nodejs/searchtest.js: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | // IMPORTANT: Change the required package name if necessary. 18 | 19 | var api = require('ibm_domino_data_api'); 20 | 21 | // IMPORTANT: Change these values to match your test environment: 22 | // 23 | // - basePath is the base URL for your Domino server. 24 | // The data service MUST be installed and enabled 25 | // on the server. Be sure to change the protocol to 26 | // http if your server doesn't support https. 27 | // 28 | // - username is the name of a user who has access to your 29 | // Domino server 30 | // 31 | // - password is the user's password 32 | // 33 | // - folder is the database folder name relative to the Domino 34 | // data directory. Use '.' if the database is in the data 35 | // directory itself. 36 | // 37 | // - database is the database file name. Use 'XPagesExt.nsf' 38 | // if your server has a copy of the XPages Extension Library 39 | // demo database. 40 | // 41 | 42 | var basePath = 'https://yourserver.yourorg.com'; 43 | var username = 'First Last'; 44 | var password = 'password'; 45 | var folder = '.'; 46 | var database = 'XPagesExt.nsf'; 47 | 48 | /* Globals */ 49 | 50 | var searchText = "Lorem"; 51 | 52 | /* Callback for document search request */ 53 | 54 | var callback = function(error, data, response) { 55 | if (error) { 56 | console.error(error); 57 | } 58 | else { 59 | debugger; 60 | if ( data.length > 0 ) { 61 | console.log('Document search API called successfully. Response follows ...\n'); 62 | for ( var i = 0; i < data.length; i++ ) { 63 | console.log('Document ' + i); 64 | console.log(' unid: ' + data[i]['@unid']); 65 | console.log(' modified: ' + data[i]['@modified']); 66 | console.log(' href: ' + data[i]['@href']); 67 | console.log(''); 68 | } 69 | } 70 | else { 71 | console.log('Document search API called successfully, but response does not contain a list of documents.'); 72 | } 73 | } 74 | }; 75 | 76 | /* Start of main routine */ 77 | 78 | // Parse command line arguments 79 | 80 | process.argv.forEach(function (val, index, array) { 81 | if ( index > 1 ) { 82 | searchText = val; 83 | } 84 | }); 85 | 86 | // Get the API instance and set the base path of 87 | // the target Domino server 88 | 89 | var docListApi = new api.DocumentListApi(); 90 | docListApi.apiClient.basePath = basePath; 91 | 92 | // Set user name and password 93 | 94 | var basic = docListApi.apiClient.authentications['basic']; 95 | basic.username = username; 96 | basic.password = password; 97 | 98 | // Set search string and maximum # of docs to return. 99 | // We limit the number of documents to 10 to avoid huge 100 | // responses, but you can change that. 101 | 102 | var opts = { 103 | 'search': searchText, 104 | 'searchmaxdocs': 10 105 | }; 106 | 107 | // Send the request 108 | 109 | console.log('Searching documents in database ' + database + ' matching ' + searchText + ' ...'); 110 | docListApi.folderDatabaseApiDataDocumentsGet(folder, database, opts, callback); 111 | -------------------------------------------------------------------------------- /client-samples/freebusy/nodejs/freeroomstest.js: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | // IMPORTANT: Change the required package name if necessary. 18 | 19 | var api = require('ibm_domino_freebusy_api'); 20 | 21 | // IMPORTANT: Change these values to match your test environment: 22 | // 23 | // - basePath is the base URL for your Domino server. 24 | // The freebusy service MUST be installed and enabled 25 | // on the server. Be sure to change the protocol to 26 | // https if necessary. 27 | // 28 | // - username is the name of a user who has access to your 29 | // Domino server 30 | // 31 | // - password is the user's password 32 | // 33 | // - site is the name of the site to search. Or you can 34 | // specify the site on the command line. 35 | // 36 | // - frOpts.capacity is number of minimum room capacity. 37 | 38 | var basePath = "https://yourserver.yourorg.com"; 39 | var username = "First Last"; 40 | var password = "password"; 41 | var site = "Your Site"; 42 | var frOpts = { 43 | 'capacity': 12 44 | }; 45 | 46 | /* ISO8601 Date formatter */ 47 | 48 | function ISODateString(d) { 49 | function pad(n) {return n<10 ? '0'+n : n} 50 | return d.getUTCFullYear() + '-' + pad(d.getUTCMonth()+1) + '-' + 51 | pad(d.getUTCDate()) + 'T' + pad(d.getUTCHours()) + ':' + 52 | pad(d.getUTCMinutes()) + ':' + pad(d.getUTCSeconds()) + 'Z' 53 | } 54 | 55 | /* Callback for freerooms request */ 56 | 57 | var frCallback = function(error, data, response) { 58 | if (error) { 59 | console.error(error); 60 | } 61 | else { 62 | if ( data.hasOwnProperty('rooms') ) { 63 | console.log('Freerooms API called successfully. Response follows ...\n'); 64 | 65 | if ( data.rooms.length > 0 ) { 66 | for ( var i = 0; i < data.rooms.length; i++ ) { 67 | console.log('name: ' + data.rooms[i].displayName + '; capacity: ' + data.rooms[i].capacity); 68 | } 69 | } 70 | else { 71 | console.log('No rooms are available!'); 72 | } 73 | } 74 | else { 75 | console.log('Freerooms API called successfully, but response does not contain rooms data.'); 76 | } 77 | } 78 | }; 79 | 80 | /* Start of main routine */ 81 | 82 | // Parse command line arguments 83 | 84 | process.argv.forEach(function (val, index, array) { 85 | if ( index > 1 ) { 86 | site = val; 87 | } 88 | }); 89 | 90 | // Get the API instance and set the base path of 91 | // the target Domino server 92 | 93 | var freerooms = new api.FreeroomsApi(); 94 | freerooms.apiClient.basePath = basePath; 95 | 96 | // Set user name and password 97 | 98 | var basic = freerooms.apiClient.authentications['basic']; 99 | basic.username = username; 100 | basic.password = password; 101 | 102 | // Send the request 103 | 104 | var start = new Date(); // Start date is now 105 | var end = new Date(start.getTime() + 30000); // End date is 30 minutes from now 106 | console.log('Requesting free rooms in the next 30 minutes for ' + site + ' ...'); 107 | freerooms.apiFreebusyFreeroomsGet(site, ISODateString(start), ISODateString(end), frOpts, frCallback); 108 | -------------------------------------------------------------------------------- /client-samples/freebusy/java/client/freebusy/test/BusyTimeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | package client.freebusy.test; 18 | 19 | import io.swagger.client.ApiClient; 20 | import io.swagger.client.ApiException; 21 | import io.swagger.client.api.BusytimeApi; 22 | import io.swagger.client.model.BusyTimeResponse; 23 | import io.swagger.client.model.ExDateTimeRange; 24 | 25 | import java.util.List; 26 | 27 | public class BusyTimeTest { 28 | 29 | public static void main(String[] args) { 30 | 31 | // IMPORTANT: Change these values to match your test environment: 32 | // 33 | // - basePath is the base URL for your Domino server. 34 | // The freebusy service MUST be installed and enabled 35 | // on the server. Be sure to change the protocol to 36 | // https if necessary. 37 | // 38 | // - user is the user name for HTTP authentication 39 | // 40 | // - password is the user's HTTP password 41 | // 42 | // - lookupName is the email address of a VALID user. 43 | // 44 | // - days is number of days of busy time data to return. 45 | // 46 | String basePath = "http://yourserver.yourorg.com"; 47 | String user = "First Last"; 48 | String password = "password"; 49 | String lookupName = "user@yourorg.com"; 50 | Integer days = 7; 51 | 52 | try { 53 | // Get the API instance and set the base path 54 | // of the target Domino server 55 | BusytimeApi busytime = new BusytimeApi(); 56 | ApiClient client = busytime.getApiClient(); 57 | client.setBasePath(basePath); 58 | client.setUsername(user); 59 | client.setPassword(password); 60 | 61 | // Request busy time for the user 62 | System.out.println("Requesting busytime for " + lookupName + " ..."); 63 | BusyTimeResponse result = busytime.apiFreebusyBusytimeGet(lookupName, null, null, null, days); 64 | 65 | // Does the response have busy time data? 66 | List ranges = result.getBusyTimes(); 67 | if (ranges != null) { 68 | 69 | // Dump the busy time blocks 70 | System.out.println("Busytime request succeeded. Response follows ...\n"); 71 | for (int i = 0; i < ranges.size(); i++) { 72 | ExDateTimeRange range = ranges.get(i); 73 | System.out.println("start: " + range.getStart().getDate() + "T" + range.getStart().getTime() 74 | + "; end: " + range.getEnd().getDate() + "T" + range.getEnd().getTime()); 75 | } 76 | } 77 | else { 78 | 79 | // Unexpected response 80 | System.out.println("Busytime request succeeded, but the response doesn't include a list of busy times."); 81 | } 82 | } 83 | catch (ApiException e) { 84 | System.err.println("Exception when calling BusytimeApi#apiFreebusyBusytimeGet"); 85 | String body = e.getResponseBody(); 86 | if (body != null) { 87 | System.err.println("Response from server ..."); 88 | System.err.println(body); 89 | } 90 | else { 91 | e.printStackTrace(); 92 | } 93 | } 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /client-samples/mail/nodejs/sendmailtest.js: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | // IMPORTANT: Change the required package name if necessary. 18 | 19 | var api = require('ibm_domino_mail_api'); 20 | 21 | // IMPORTANT: Change these values to match your test environment: 22 | // 23 | // - basePath is the base URL for your Domino server. 24 | // The mail service MUST be installed and enabled 25 | // on the server. Be sure to change the protocol to 26 | // http if your server doesn't support https. 27 | // 28 | // - username is the name of a user who has access to a 29 | // mail file on your Domino server 30 | // 31 | // - password is the user's password 32 | // 33 | // - folder is the mail file folder name relative to the Domino 34 | // data directory. Use '.' if the mail file is in the data 35 | // directory itself. 36 | // 37 | // - database is the mail file name. 38 | // 39 | // - sendTo is the email address of a recipient. Or you can 40 | // specify the recipient on the command line. This test 41 | // sends a message to one recipient. 42 | // 43 | 44 | var basePath = 'https://yourserver.yourorg.com'; 45 | var username = 'First Last'; 46 | var password = 'password'; 47 | var folder = 'mail'; 48 | var database = 'database.nsf'; 49 | var sendTo = 'recipient@yourorg.com'; 50 | 51 | /* Callback for send request */ 52 | 53 | var callback = function(error, data, response) { 54 | if (error) { 55 | console.error(error); 56 | } 57 | else { 58 | var location = null; 59 | if ( response != null && response.header != null && response.header['location'] != null ) { 60 | location = response.header['location']; 61 | } 62 | 63 | if ( location != null ) { 64 | console.log('Send mail request succeeded. New document URL follows ...'); 65 | console.log(' ' + response.header['location'] + '\n'); 66 | } 67 | else { 68 | console.log('Send mail request succeeded, but response does not contain a Location header.'); 69 | } 70 | } 71 | }; 72 | 73 | /* Start of main routine */ 74 | 75 | // Parse command line arguments 76 | 77 | process.argv.forEach(function (val, index, array) { 78 | if ( index > 1 ) { 79 | sendTo = val; 80 | } 81 | }); 82 | 83 | // Get the API instance and set the base path of 84 | // the target Domino server 85 | 86 | var messageApi = new api.MessageApi(); 87 | messageApi.apiClient.basePath = basePath; 88 | 89 | // Set user name and password 90 | 91 | var basic = messageApi.apiClient.authentications['basic']; 92 | basic.username = username; 93 | basic.password = password; 94 | 95 | // Create a local representation of the message to send 96 | 97 | var message = new api.Message(); 98 | message.subject = "Test message from Swagger generated Javascript client code"; 99 | message.to = [ { 'email': sendTo } ]; 100 | message.content = [ 101 | { 102 | 'contentType': 'multipart/alternative; Boundary=abcdefg' 103 | }, 104 | { 105 | 'contentType': 'text/plain', 106 | 'boundary': '--abcdefg', 107 | 'data': 'This is a test.' 108 | }, 109 | { 110 | 'contentType': 'text/html', 111 | 'boundary': '--abcdefg', 112 | 'data': 'This is a test.

This is only a test!' 113 | } 114 | ]; 115 | 116 | // Send the request 117 | 118 | console.log('Sending message to ' + sendTo + ' ...'); 119 | messageApi.folderDatabaseApiMailOutboxPost(folder, database, message, callback); 120 | -------------------------------------------------------------------------------- /client-samples/data/java/client/data/test/DatabaseListTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | package client.data.test; 18 | 19 | import io.swagger.client.ApiClient; 20 | import io.swagger.client.ApiException; 21 | import io.swagger.client.api.DatabaseListApi; 22 | import io.swagger.client.model.Database; 23 | import io.swagger.client.model.DatabaseListResponse; 24 | 25 | public class DatabaseListTest { 26 | 27 | private DatabaseListApi _api = null; 28 | 29 | public DatabaseListTest(String basePath, String user, String password) { 30 | 31 | _api = new DatabaseListApi(); 32 | ApiClient client = _api.getApiClient(); 33 | client.setBasePath(basePath); 34 | client.setUsername(user); 35 | client.setPassword(password); 36 | } 37 | 38 | public static void main(String[] args) { 39 | 40 | // IMPORTANT: Change these values to match your test environment: 41 | // 42 | // - basePath is the base URL for your Domino server. 43 | // The data service MUST be installed and enabled 44 | // on the server. Be sure to change the protocol to 45 | // https if necessary. 46 | // 47 | // - username is the user name of someone with access 48 | // the server. 49 | // 50 | // - password is the user's password. 51 | // 52 | String basePath = "http://yourserver.yourorg.com"; 53 | String username = "First Last"; 54 | String password = "password"; 55 | 56 | DatabaseListTest test = new DatabaseListTest(basePath, username, password); 57 | test.readDatabaseList(); 58 | } 59 | 60 | /** 61 | * Reads the list of databases on a server. 62 | */ 63 | public void readDatabaseList() { 64 | 65 | try { 66 | System.out.println("Requesting a list of databases ..."); 67 | DatabaseListResponse result = _api.apiDataGet(); 68 | 69 | if ( result.size() > 0 ) { 70 | System.out.println("Request succeeded. An excerpt from the response follows ...\n"); 71 | 72 | for ( int i = 0; i < result.size(); i++ ) { 73 | if ( i == 5 ) 74 | break; 75 | 76 | Database database = result.get(i); 77 | System.out.println("Database " + i); 78 | System.out.println(" title: " + database.getTitle()); 79 | System.out.println(" filepath: " + database.getFilepath()); 80 | System.out.println(" replicaid: " + database.getReplicaid()); 81 | System.out.println(" template: " + database.getTemplate()); 82 | System.out.println(" href: " + database.getHref()); 83 | System.out.println(); 84 | } 85 | } 86 | else { 87 | System.out.println("Request succeeded, but the response doesn't include a list of databases."); 88 | } 89 | } 90 | catch (ApiException e) { 91 | System.err.println("Exception when calling DatabaseListApi#apiDataGet"); 92 | String body = e.getResponseBody(); 93 | if (body != null) { 94 | System.err.println("Response from server ..."); 95 | System.err.println(body); 96 | } 97 | else { 98 | e.printStackTrace(); 99 | } 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /client-samples/mail/nodejs/messagelisttest.js: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | // IMPORTANT: Change the required package name if necessary. 18 | 19 | var api = require('ibm_domino_mail_api'); 20 | 21 | // IMPORTANT: Change these values to match your test environment: 22 | // 23 | // - basePath is the base URL for your Domino server. 24 | // The mail service MUST be installed and enabled 25 | // on the server. Be sure to change the protocol to 26 | // http if your server doesn't support https. 27 | // 28 | // - username is the name of a user who has access to a 29 | // mail file on your Domino server 30 | // 31 | // - password is the user's password 32 | // 33 | // - folder is the mail file folder name relative to the Domino 34 | // data directory. Use '.' if the mail file is in the data 35 | // directory itself. 36 | // 37 | // - database is the mail file name. 38 | // 39 | var basePath = 'http://yourserver.yourorg.com'; 40 | var username = 'First Last'; 41 | var password = 'password'; 42 | var folder = 'mail'; 43 | var database = 'database.nsf'; 44 | 45 | /* Globals */ 46 | 47 | var view = 'inbox'; 48 | 49 | /* Callback for message list request */ 50 | 51 | var callback = function(error, data, response) { 52 | if (error) { 53 | console.error(error); 54 | } 55 | else { 56 | if ( data != null || data.length == 0 ) { 57 | console.log('Request succeeded. Response follows ...\n'); 58 | 59 | for ( var i = 0; i < data.length; i++ ) { 60 | console.log('Message ' + i); 61 | console.log(' subject: ' + data[i].subject); 62 | console.log(' date: ' + data[i].date); 63 | 64 | if ( view == "sent" || view == 'drafts' ) { 65 | console.log(' to: ' + data[i].to.displayName); 66 | } 67 | else { 68 | console.log(' from: ' + data[i].from.displayName); 69 | } 70 | 71 | console.log(); 72 | } 73 | } 74 | else { 75 | console.log('Send mail request succeeded, but response does not contain a Location header.'); 76 | } 77 | } 78 | }; 79 | 80 | /* Start of main routine */ 81 | 82 | // Parse command line arguments 83 | 84 | process.argv.forEach(function (val, index, array) { 85 | if ( index > 1 ) { 86 | view = val; 87 | } 88 | }); 89 | 90 | // Get the API instance and set the base path of 91 | // the target Domino server 92 | 93 | var api = new api.MessageListApi(); 94 | api.apiClient.basePath = basePath; 95 | 96 | // Set user name and password 97 | 98 | var basic = api.apiClient.authentications['basic']; 99 | basic.username = username; 100 | basic.password = password; 101 | 102 | // Set up options 103 | 104 | var opts = { 105 | 'count': 5, 106 | 'sortcolumn': 'date', 107 | 'sortorder': 'descending' 108 | }; 109 | 110 | // Send the request 111 | 112 | if ( view == 'sent' ) { 113 | console.log('Reading sent view from ' + database + ' ...'); 114 | api.folderDatabaseApiMailSentGet(folder, database, opts, callback); 115 | } 116 | else if ( view == 'drafts' ) { 117 | console.log('Reading drafts view from ' + database + ' ...'); 118 | api.folderDatabaseApiMailDraftsGet(folder, database, opts, callback); 119 | } 120 | else if ( view == 'trash' ) { 121 | console.log('Reading trash view from ' + database + ' ...'); 122 | api.folderDatabaseApiMailTrashGet(folder, database, opts, callback); 123 | } 124 | else if ( view == 'inbox' ) { 125 | console.log('Reading inbox from ' + database + ' ...'); 126 | api.folderDatabaseApiMailInboxGet(folder, database, opts, callback); 127 | } 128 | else { 129 | console.log('Error. Unknown view: ' + view); 130 | } 131 | -------------------------------------------------------------------------------- /client-samples/calendar/nodejs/noticetest.js: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | // IMPORTANT: Change the required package name if necessary. 18 | 19 | var api = require('ibm_domino_calendar_api'); 20 | 21 | // IMPORTANT: Change these values to match your test environment: 22 | // 23 | // - basePath is the base URL for your Domino server. 24 | // The calendar service MUST be installed and enabled 25 | // on the server. Be sure to change the protocol to 26 | // http if your sever doesn't support https. 27 | // 28 | // - username is the name of a user who has access to your 29 | // Domino server 30 | // 31 | // - password is the user's password 32 | // 33 | // - folder is the mail file folder name 34 | // 35 | // - database is the mail file database name 36 | // 37 | 38 | var basePath = "https://yourserver.yourorg.com"; 39 | var username = "First Last"; 40 | var password = "password"; 41 | var folder = "mail"; 42 | var database = "database.nsf" 43 | var accept = false; 44 | var noticeApi = new api.NoticeApi(); 45 | 46 | /* Callback for accept request */ 47 | 48 | var acceptCallback = function(error, data, response) { 49 | if (error) { 50 | console.error(error); 51 | } 52 | else { 53 | console.log('Notice accepted!'); 54 | } 55 | } 56 | 57 | /* Callback for invitations request */ 58 | 59 | var invCallback = function(error, data, response) { 60 | if (error) { 61 | console.error(error); 62 | } 63 | else if ( null == data ) { 64 | console.log('Invitations API called succesfully, but the response was empty.'); 65 | } 66 | else { 67 | if ( data.hasOwnProperty('notices') ) { 68 | console.log('Invitations API called successfully. Response follows ...\n'); 69 | for ( var i = 0; i < data.notices.length; i++ ) { 70 | console.log('summary: ' + data.notices[i].summary); 71 | console.log('href: ' + data.notices[i].href); 72 | console.log(''); 73 | 74 | // Send accept request 75 | if ( accept ) { 76 | var href = data.notices[i].href; 77 | var index = href.lastIndexOf('/'); 78 | if ( index != -1 ) { 79 | var id = href.substring(index+1); 80 | 81 | // Add a comment to the accept action 82 | var body = new api.ActionRequest(); 83 | body.comments = "I'll be there!"; 84 | var options = { 85 | 'action': body 86 | }; 87 | 88 | // Accept it 89 | console.log('Accepting notice ' + id + ' ...'); 90 | noticeApi.folderDatabaseApiCalendarNoticesIdActionPut(folder, database, id, "accept", options, acceptCallback); 91 | console.log(''); 92 | } 93 | } 94 | } 95 | } 96 | else { 97 | console.log('Invitations API called successfully, but response does not contain notices.'); 98 | } 99 | } 100 | }; 101 | 102 | /* Start of main routine */ 103 | 104 | // Parse command line arguments 105 | 106 | process.argv.forEach(function (val, index, array) { 107 | if ( index > 1 ) { 108 | if ( val == "-a" ) { 109 | accept = true; 110 | } 111 | } 112 | }); 113 | 114 | // Get the API instance and set the base path of 115 | // the target Domino server 116 | 117 | var noticeListApi = new api.NoticeListApi(); 118 | noticeListApi.apiClient.basePath = basePath; 119 | 120 | // Set user name and password 121 | 122 | var basic = noticeListApi.apiClient.authentications['basic']; 123 | basic.username = username; 124 | basic.password = password; 125 | 126 | // Send the request 127 | 128 | console.log('Requesting invitations for ' + username + ' ...'); 129 | noticeListApi.folderDatabaseApiCalendarInvitationsGet(folder, database, null, invCallback); 130 | -------------------------------------------------------------------------------- /client-samples/freebusy/java/client/freebusy/test/FreeRoomsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | package client.freebusy.test; 18 | 19 | import io.swagger.client.ApiClient; 20 | import io.swagger.client.ApiException; 21 | import io.swagger.client.api.FreeroomsApi; 22 | import io.swagger.client.model.FreeRoomsResponse; 23 | import io.swagger.client.model.Room; 24 | 25 | import java.text.SimpleDateFormat; 26 | import java.util.Date; 27 | import java.util.List; 28 | import java.util.TimeZone; 29 | 30 | public class FreeRoomsTest { 31 | 32 | public static void main(String[] args) { 33 | 34 | // IMPORTANT: Change these values to match your test environment: 35 | // 36 | // - basePath is the base URL for your Domino server. 37 | // The freebusy service MUST be installed and enabled 38 | // on the server. Be sure to change the protocol to 39 | // https if necessary. 40 | // 41 | // - user is the user name for HTTP authentication 42 | // 43 | // - password is the user's HTTP password 44 | // 45 | // - site is the name of a site to search. 46 | // 47 | // - capacity is the minimum room capacity. 48 | // 49 | String basePath = "http://yourserver.yourorg.com"; 50 | String user = "First Last"; 51 | String password = "password"; 52 | String site = "Your Site"; 53 | Integer capacity = 12; 54 | 55 | // Get an ISO8601 date formatter 56 | TimeZone tz = TimeZone.getTimeZone("UTC"); 57 | SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); 58 | formatter.setTimeZone(tz); 59 | 60 | // We'll request rooms available for the next 30 minutes 61 | Date start = new Date(); 62 | Date end = new Date(start.getTime() + 30000); 63 | 64 | try { 65 | // Get the API instance and set the base path 66 | // of the target Domino server 67 | FreeroomsApi freerooms = new FreeroomsApi(); 68 | ApiClient client = freerooms.getApiClient(); 69 | client.setBasePath(basePath); 70 | client.setUsername(user); 71 | client.setPassword(password); 72 | 73 | // Request available rooms 74 | System.out.println("Requesting free rooms in the next 30 minutes for " + site + " ..."); 75 | FreeRoomsResponse result = freerooms.apiFreebusyFreeroomsGet(site, formatter.format(start), 76 | formatter.format(end), capacity); 77 | 78 | // Does the response have rooms 79 | List rooms = result.getRooms(); 80 | if (rooms != null) { 81 | 82 | // Dump the list of available rooms 83 | System.out.println("Freerooms request succeeded. Response follows ...\n"); 84 | for (int i = 0; i < rooms.size(); i++) { 85 | Room room = rooms.get(i); 86 | System.out.println("name: " + room.getDisplayName() + "; capacity: " + room.getCapacity()); 87 | } 88 | } 89 | else { 90 | 91 | // No rooms available or unexpected response 92 | System.out.println("Freerooms request succeeded, but the response doesn't include a list of rooms."); 93 | } 94 | } 95 | catch (ApiException e) { 96 | System.err.println("Exception when calling FreeroomsApi#apiFreebusyFreeroomsGet"); 97 | String body = e.getResponseBody(); 98 | if (body != null) { 99 | System.err.println("Response from server ..."); 100 | System.err.println(body); 101 | } 102 | else { 103 | e.printStackTrace(); 104 | } 105 | } 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /client-samples/mail/java/client/mail/test/QuotaTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | package client.mail.test; 18 | 19 | import io.swagger.client.ApiClient; 20 | import io.swagger.client.ApiException; 21 | import io.swagger.client.api.QuotaApi; 22 | import io.swagger.client.model.QuotaResponse; 23 | 24 | public class QuotaTest { 25 | 26 | private QuotaApi _api; 27 | 28 | public QuotaTest(String basePath, String user, String password) { 29 | _api = new QuotaApi(); 30 | ApiClient client = _api.getApiClient(); 31 | client.setBasePath(basePath); 32 | client.setUsername(user); 33 | client.setPassword(password); 34 | } 35 | 36 | public static void main(String[] args) { 37 | 38 | // IMPORTANT: Change these values to match your test environment: 39 | // 40 | // - basePath is the base URL for your Domino server. 41 | // The mail service MUST be installed and enabled 42 | // on the server. Be sure to change the protocol to 43 | // https if necessary. 44 | // 45 | // - folder is the mail file database folder. The folder is relative 46 | // to the Domino data directory. Use "." if the mail file 47 | // is in the data directory itself. 48 | // 49 | // - database is the mail file database name. 50 | // 51 | // - user is the user name of the owner of the mail file specified by 52 | // /{folder}/{database}. 53 | // 54 | // - password is the user's password. 55 | // 56 | String basePath = "http://yourserver.yourorg.com"; 57 | String folder = "mail"; 58 | String database = "database.nsf"; 59 | String user = "First Last"; 60 | String password = "password"; 61 | 62 | // Create an instance of the test class 63 | QuotaTest test = new QuotaTest(basePath, user, password); 64 | 65 | // Read the inbox 66 | test.readQuota(folder, database); 67 | } 68 | 69 | /** 70 | * Reads the quota and dumps it to the console. 71 | * 72 | * @param folder 73 | * @param database 74 | */ 75 | private void readQuota(String folder, String database) { 76 | try { 77 | 78 | // Read the quota 79 | System.out.println("Reading quota from " + folder + "/" + database + " ..."); 80 | QuotaResponse quota = _api.folderDatabaseApiMailQuotaGet(folder, database); 81 | 82 | // Does the response have quota information? 83 | if ( quota != null ) { 84 | boolean enabled = false; 85 | if ( quota.getEnabled() != null ) { 86 | enabled = quota.getEnabled(); 87 | } 88 | 89 | // Dump the quota 90 | System.out.println("Read quota request succeeded. Response follows ...\n"); 91 | System.out.println(" enabled: " + enabled); 92 | System.out.println(" actualSize: " + quota.getActualSize()); 93 | System.out.println(" usedSize: " + quota.getUsedSize()); 94 | 95 | if ( enabled ) { 96 | System.out.println(" quotaSize: " + quota.getQuotaSize()); 97 | System.out.println(" warningSize: " + quota.getWarningSize()); 98 | } 99 | 100 | System.out.println(); 101 | } 102 | else { 103 | 104 | // Unexpected response 105 | System.out.println("Read quota request succeeded, but the response doesn't include quota information."); 106 | } 107 | } 108 | catch (ApiException e) { 109 | System.err.println("Exception when calling QuotaApi#folderDatabaseApiMailQuotaGet"); 110 | String body = e.getResponseBody(); 111 | if (body != null) { 112 | System.err.println("Response from server ..."); 113 | System.err.println(body); 114 | } 115 | else { 116 | e.printStackTrace(); 117 | } 118 | } 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /client-samples/calendar/nodejs/README.md: -------------------------------------------------------------------------------- 1 | 15 | 16 | # Node.js samples using the DAS Calendar API 17 | Sample code showing use of Domino Access Services (DAS) with Swagger 18 | generated client code. You can use this code to test calendar client 19 | code generated by 20 | [Swagger Codegen](https://github.com/swagger-api/swagger-codegen). 21 | 22 | ### Prerequisites 23 | - A Domino server with the calendar API installed and enabled. 24 | - A Node.js runtime environment. 25 | - A Node.js package generated from **calendar.yaml**. For example, 26 | you can use the [online Swagger editor](http://editor2.swagger.io) 27 | to import **calendar.yaml** and then generate a "Javascript" client. 28 | 29 | # Instructions 30 | These instructions show how to install and run [noticetest.js](noticetest.js). 31 | To run a different calendar client sample, follow these same instructions 32 | and substitute file names where appropriate. 33 | 34 | First create a root folder and two sub-folders as shown below: 35 | 36 | ``` 37 | /tests 38 | /tests/ibm_domino_calendar_api 39 | /tests/noticetest 40 | ``` 41 | 42 | The root folder name is not important. Choose a name other than 43 | **/tests** if necessary. 44 | 45 | ### Unzip the generated client code 46 | Next unzip the generated code to **/tests/ibm_domino_calendar_api**. 47 | When you are finished, the contents of the folder should look 48 | something like this: 49 | 50 | ``` 51 | docs 52 | src 53 | test 54 | .swagger-codegen-ignore 55 | .travis.yml 56 | git_push.sh 57 | mocha.opts 58 | package.json 59 | README.md 60 | ``` 61 | 62 | ### Create your Node.js application 63 | Now use **npm** to initialize your Node.js application. Use a Node.js 64 | command shell to execute the following commands: 65 | 66 | ``` 67 | cd /tests/noticetest 68 | npm init 69 | ``` 70 | 71 | The **npm** command will prompt you for information about your 72 | application. Be sure to specify **noticetest.js** as the 73 | entry point. Otherwise, you can accept the default values 74 | as shown below: 75 | 76 | ``` 77 | name: (noticetest) 78 | version: (1.0.0) 79 | description: Calendar API test 80 | entry point: (index.js) noticetest.js 81 | test command: 82 | git repository: 83 | keywords: 84 | author: 85 | license: (ISC) 86 | ``` 87 | 88 | Use **npm** to make your application dependent on **ibm_domino_calendar_api** 89 | (the generated client code): 90 | 91 | ``` 92 | npm install --save ../ibm_domino_calendar_api 93 | ``` 94 | 95 | Download [noticetest.js](noticetest.js) to the **/tests/noticetest** folder. 96 | Then open your local copy of **noticetest.js** in your favorite text editor 97 | and customize the following values for your environment: 98 | 99 | ```javascript 100 | // IMPORTANT: Change these values to match your test environment: 101 | // 102 | // - basePath is the base URL for your Domino server. 103 | // The calendar service MUST be installed and enabled 104 | // on the server. Be sure to change the protocol to 105 | // http if your sever doesn't support https. 106 | // 107 | // - username is the name of a user who has access to your 108 | // Domino server 109 | // 110 | // - password is the user's password 111 | // 112 | // - folder is the mail file folder name 113 | // 114 | // - database is the mail file database name 115 | // 116 | 117 | var basePath = "https://yourserver.yourorg.com"; 118 | var username = "First Last"; 119 | var password = "password"; 120 | var folder = "mail"; 121 | var database = "database.nsf" 122 | ``` 123 | 124 | ### Run your Node.js application 125 | After saving your local changes, return to the Node.js command shell to run 126 | your application: 127 | 128 | ``` 129 | node noticetest.js 130 | ``` 131 | 132 | The following is some sample output from a successful run: 133 | 134 | ``` 135 | /tests/noticetest> node noticetest.js 136 | Requesting invitations for Duke Lawson ... 137 | Invitations API called successfully. Response follows ... 138 | 139 | summary: Pi Day celebration 140 | href: /mail/dlawson.nsf/api/calendar/notices/FED0A59156EF7B31852580CE00539688 141 | 142 | summary: St. Patrick's Day 143 | href: /mail/dlawson.nsf/api/calendar/notices/F600D2B8AC497393852580CE0053A66A 144 | ``` 145 | 146 | In other words, the **noticetest.js** application displays a list of the 147 | unprocessed invitations for the specified user. You can also accept the 148 | invitations with the optional **-a** parameter. Try the following 149 | command only if you are sure you want to accept all invitations: 150 | 151 | ``` 152 | node noticetest.js -a 153 | ``` 154 | -------------------------------------------------------------------------------- /client-samples/calendar/java/client/calendar/test/EventListTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | package client.calendar.test; 18 | 19 | import io.swagger.client.ApiClient; 20 | import io.swagger.client.ApiException; 21 | import io.swagger.client.api.EventListApi; 22 | import io.swagger.client.model.Event; 23 | import io.swagger.client.model.EventListResponse; 24 | 25 | import java.util.List; 26 | 27 | public class EventListTest { 28 | 29 | public static void main(String[] args) { 30 | 31 | // IMPORTANT: Change these values to match your test environment: 32 | // 33 | // - basePath is the base URL for your Domino server. 34 | // The calendar service MUST be installed and enabled 35 | // on the server. Be sure to change the protocol to 36 | // https if necessary. 37 | // 38 | // - folder is mail file database folder. 39 | // 40 | // - database is the mail file database name. 41 | // 42 | // - user is the user name of the mail file owner (for HTTP authentication) 43 | // 44 | // - password is the owner's HTTP password 45 | // 46 | String basePath = "http://yourserver.yourorg.com"; 47 | String folder = "mail"; 48 | String database = "database.nsf"; 49 | String user = "First Last"; 50 | String password = "password"; 51 | 52 | try { 53 | // Get the API instance and set the base path 54 | // of the target Domino server 55 | EventListApi eventsApi = new EventListApi(); 56 | ApiClient client = eventsApi.getApiClient(); 57 | client.setBasePath(basePath); 58 | client.setUsername(user); 59 | client.setPassword(password); 60 | 61 | // Request a list of events 62 | System.out.println("Requesting events from " + folder + "/" + database + " ..."); 63 | EventListResponse result = eventsApi.folderDatabaseApiCalendarEventsGet(folder, database, 64 | null, // format 65 | null, // since 66 | null, // before 67 | null, // sincenow 68 | null, // days 69 | null, // count 70 | null, // start 71 | null); // fields 72 | 73 | // Does the response have events? 74 | List events = result.getEvents(); 75 | if (events != null) { 76 | 77 | // Dump the events 78 | System.out.println("Get events request succeeded. Response follows ...\n"); 79 | for (int i = 0; i < events.size(); i++) { 80 | Event event = events.get(i); 81 | System.out.println("Event " + i); 82 | System.out.println(" summary: " + event.getSummary()); 83 | System.out.println(" href: " + event.getHref()); 84 | 85 | String start = event.getStart().getDate(); 86 | if (event.getStart().getTime() != null) { 87 | start += "T" + event.getStart().getTime(); 88 | } 89 | System.out.println(" start: " + start); 90 | 91 | String end = event.getEnd().getDate(); 92 | if (event.getEnd().getTime() != null) { 93 | end += "T" + event.getEnd().getTime(); 94 | } 95 | System.out.println(" end: " + end); 96 | 97 | System.out.println(); 98 | } 99 | } 100 | else { 101 | 102 | // Unexpected response 103 | System.out.println("Get events request succeeded, but the response doesn't include a list of events."); 104 | } 105 | } 106 | catch (ApiException e) { 107 | System.err.println("Exception when calling EventListApi#folderDatabaseApiCalendarEventsGet"); 108 | String body = e.getResponseBody(); 109 | if (body != null) { 110 | System.err.println("Response from server ..."); 111 | System.err.println(body); 112 | } 113 | else { 114 | e.printStackTrace(); 115 | } 116 | } 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /client-samples/data/java/client/data/test/DocumentListTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | package client.data.test; 18 | 19 | import io.swagger.client.ApiClient; 20 | import io.swagger.client.ApiException; 21 | import io.swagger.client.api.DocumentListApi; 22 | import io.swagger.client.model.DocumentListEntry; 23 | import io.swagger.client.model.DocumentListResponse; 24 | 25 | public class DocumentListTest { 26 | 27 | private DocumentListApi _api = null; 28 | 29 | public DocumentListTest(String basePath, String user, String password) { 30 | 31 | _api = new DocumentListApi(); 32 | ApiClient client = _api.getApiClient(); 33 | client.setBasePath(basePath); 34 | client.setUsername(user); 35 | client.setPassword(password); 36 | } 37 | 38 | public static void main(String[] args) { 39 | 40 | // IMPORTANT: Change these values to match your test environment: 41 | // 42 | // - basePath is the base URL for your Domino server. 43 | // The data service MUST be installed and enabled 44 | // on the server. Be sure to change the protocol to 45 | // https if necessary. 46 | // 47 | // - username is the user name of someone with access 48 | // the server. 49 | // 50 | // - password is the user's password. 51 | // 52 | // - folder is database folder name relative to the Domino 53 | // data directory. Use "." if the database is in the 54 | // data directory itself. 55 | // 56 | // - database is the name of the database. The database 57 | // must allow access from the data service. Use 58 | // "XPagesExt.nsf" if your server has a copy of the 59 | // XPages Extension Library demo database. 60 | // 61 | // - query is a search string 62 | // 63 | String basePath = "http://yourserver.yourorg.com"; 64 | String username = "First Last"; 65 | String password = "password"; 66 | String folder = "."; 67 | String database = "XPagesExt.nsf"; 68 | String query = "Lorem"; 69 | 70 | DocumentListTest test = new DocumentListTest(basePath, username, password); 71 | test.searchDocumentList(folder, database, query); 72 | } 73 | 74 | /** 75 | * Searches a database for documents matching a query string. 76 | * 77 | * @param folder 78 | * @param database 79 | * @param view 80 | */ 81 | public void searchDocumentList(String folder, String database, String query) { 82 | 83 | try { 84 | // Send search request. 85 | 86 | // NOTE: We limit the search results to 10 documents to avoid huge responses. 87 | // You can change the limit if you want. 88 | 89 | System.out.println("Searching database " + database + " for documents matching " + query + " ..."); 90 | DocumentListResponse result = _api.folderDatabaseApiDataDocumentsGet( 91 | folder, database, query, 10, null); 92 | 93 | if ( result.size() > 0 ) { 94 | System.out.println("Request succeeded. The response follows ...\n"); 95 | 96 | for ( int i = 0; i < result.size(); i++ ) { 97 | DocumentListEntry entry = result.get(i); 98 | System.out.println("Entry " + i); 99 | 100 | String unid = entry.getUnid(); 101 | System.out.println(" unid: " + unid); 102 | 103 | String modified = entry.getModified(); 104 | System.out.println(" modified: " + modified); 105 | 106 | String href = entry.getHref(); 107 | System.out.println(" href: " + href); 108 | 109 | System.out.println(); 110 | } 111 | } 112 | else { 113 | System.out.println("Request succeeded, but the response doesn't include a list of document entries."); 114 | } 115 | } 116 | catch (ApiException e) { 117 | System.err.println("Exception when calling DocumentListApi#folderDatabaseApiDataDocumentsGet"); 118 | String body = e.getResponseBody(); 119 | if (body != null) { 120 | System.err.println("Response from server ..."); 121 | System.err.println(body); 122 | } 123 | else { 124 | e.printStackTrace(); 125 | } 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /client-samples/data/nodejs/documenttest.js: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | // IMPORTANT: Change the required package name if necessary. 18 | 19 | var api = require('ibm_domino_data_api'); 20 | 21 | // IMPORTANT: Change these values to match your test environment: 22 | // 23 | // - basePath is the base URL for your Domino server. 24 | // The data service MUST be installed and enabled 25 | // on the server. Be sure to change the protocol to 26 | // http if your server doesn't support https. 27 | // 28 | // - username is the name of a user who has access to your 29 | // Domino server 30 | // 31 | // - password is the user's password 32 | // 33 | // - folder is the database folder name relative to the Domino 34 | // data directory. Use '.' if the database is in the data 35 | // directory itself. 36 | // 37 | // - database is the database file name. Use 'XPagesExt.nsf' 38 | // if your server has a copy of the XPages Extension Library 39 | // demo database. 40 | // 41 | // - opts.form is the name of a form in the database. 42 | 43 | var basePath = 'https://yourserver.yourorg.com'; 44 | var username = 'First Last'; 45 | var password = 'password'; 46 | var folder = '.'; 47 | var database = 'XPagesExt.nsf'; 48 | var opts = { 49 | 'form': 'AllTypes', 50 | 'computewithform': true 51 | }; 52 | 53 | /* Runtime globals */ 54 | 55 | var unid = null; 56 | 57 | /* Callback for the document delete request */ 58 | 59 | var deleteCallback = function(error, data, response) { 60 | if (error) { 61 | console.error(error); 62 | } 63 | else { 64 | console.log('Document delete request succeeded.'); 65 | } 66 | } 67 | 68 | /* Callback for the document read request */ 69 | 70 | var readCallback = function(error, data, response) { 71 | if (error) { 72 | console.error(error); 73 | } 74 | else { 75 | if ( data != null ) { 76 | // Dump the document 77 | console.log('Document read request succeeded. Response follows ...\n'); 78 | console.log(' fldText: ' + data['fldText']); 79 | console.log(' fldNumber: ' + data['fldNumber']); 80 | console.log(' fldDateTime: ' + data['fldDateTime'].data); 81 | 82 | // Delete the document 83 | console.log(''); 84 | console.log('Deleting document ' + unid + '...'); 85 | docApi.folderDatabaseApiDataDocumentsUnidDocUnidDelete(folder, database, unid, deleteCallback); 86 | } 87 | else { 88 | console.log('Document read request succeeded, but response is empty.'); 89 | } 90 | } 91 | }; 92 | 93 | /* Callback for document create request */ 94 | 95 | var createCallback = function(error, data, response) { 96 | if (error) { 97 | console.error(error); 98 | } 99 | else { 100 | var location = null; 101 | if ( response != null && response.header != null && response.header['location'] != null ) { 102 | location = response.header['location']; 103 | } 104 | 105 | if ( location != null ) { 106 | console.log('Document create request succeeded. New document URL follows ...'); 107 | console.log(' ' + response.header['location'] + '\n'); 108 | 109 | // Extract the UNID from the document URL 110 | var index = location.lastIndexOf('/'); 111 | if ( index != -1 ) { 112 | unid = location.substring(index+1); 113 | } 114 | 115 | // Send a document read request 116 | if ( unid != null ) { 117 | console.log('Reading document ' + unid + '...'); 118 | docApi.folderDatabaseApiDataDocumentsUnidDocUnidGet(folder, database, unid, 119 | {'strongtype': true}, // strongtype=true renders DateTime values as objects 120 | readCallback); 121 | } 122 | } 123 | else { 124 | console.log('Document create request succeeded, but response does not include a Location header.'); 125 | } 126 | } 127 | }; 128 | 129 | /* Start of main routine */ 130 | 131 | // Get the API instance and set the base path of 132 | // the target Domino server 133 | 134 | var docApi = new api.DocumentApi(); 135 | docApi.apiClient.basePath = basePath; 136 | 137 | // Set user name and password 138 | 139 | var basic = docApi.apiClient.authentications['basic']; 140 | basic.username = username; 141 | basic.password = password; 142 | 143 | // Create the document model 144 | 145 | var doc = new api.Document(); 146 | doc.fldText = "Created by a Node.js client using Swagger generated code"; 147 | doc.fldNumber = 999; 148 | doc.fldDateTime = {'data': '2017-09-01T00:00:00Z', 'type': 'datetime'}; 149 | 150 | // Send the create request 151 | 152 | console.log('Creating a new document in database ' + database + ' ...'); 153 | docApi.folderDatabaseApiDataDocumentsPost(folder, database, doc, opts, createCallback); 154 | -------------------------------------------------------------------------------- /client-samples/data/java/client/data/test/ViewDesignTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | package client.data.test; 18 | 19 | import io.swagger.client.ApiClient; 20 | import io.swagger.client.ApiException; 21 | import io.swagger.client.api.ViewDesignApi; 22 | import io.swagger.client.model.ViewColumnDesign; 23 | import io.swagger.client.model.ViewDesignResponse; 24 | 25 | public class ViewDesignTest { 26 | 27 | private ViewDesignApi _api = null; 28 | 29 | public ViewDesignTest(String basePath, String user, String password) { 30 | 31 | _api = new ViewDesignApi(); 32 | ApiClient client = _api.getApiClient(); 33 | client.setBasePath(basePath); 34 | client.setUsername(user); 35 | client.setPassword(password); 36 | } 37 | 38 | public static void main(String[] args) { 39 | 40 | // IMPORTANT: Change these values to match your test environment: 41 | // 42 | // - basePath is the base URL for your Domino server. 43 | // The data service MUST be installed and enabled 44 | // on the server. Be sure to change the protocol to 45 | // https if necessary. 46 | // 47 | // - username is the user name of someone with access 48 | // the server. 49 | // 50 | // - password is the user's password. 51 | // 52 | // - folder is database folder name relative to the Domino 53 | // data directory. Use "." if the database is in the 54 | // data directory itself. 55 | // 56 | // - database is the name of the database. The database 57 | // must allow access from the data service. Use 58 | // "XPagesExt.nsf" if your server has a copy of the 59 | // XPages Extension Library demo database. 60 | // 61 | // - viewName is the name of a view in the database. 62 | // The view must allow access from the data service. 63 | // 64 | String basePath = "http://yourserver.yourorg.com"; 65 | String username = "First Last"; 66 | String password = "password"; 67 | String folder = "."; 68 | String database = "XPagesExt.nsf"; 69 | String viewName = "AllTypes"; 70 | 71 | ViewDesignTest test = new ViewDesignTest(basePath, username, password); 72 | test.readViewDesign(folder, database, viewName); 73 | } 74 | 75 | /** 76 | * Reads a view design and writes the response to the console. 77 | * 78 | * @param folder 79 | * @param database 80 | * @param view 81 | */ 82 | public void readViewDesign(String folder, String database, String view) { 83 | 84 | try { 85 | System.out.println("Requesting the design of view " + view + "..."); 86 | ViewDesignResponse result = _api.folderDatabaseApiDataCollectionsNameViewNameDesignGet( 87 | folder, database, view); 88 | 89 | if ( result.size() > 0 ) { 90 | System.out.println("Request succeeded. An excerpt from the response follows ...\n"); 91 | 92 | for ( int i = 0; i < result.size(); i++ ) { 93 | if ( i == 5 ) 94 | break; 95 | 96 | ViewColumnDesign column = result.get(i); 97 | System.out.println("Column " + i); 98 | 99 | String name = column.getName(); 100 | System.out.println(" name: " + name); 101 | 102 | String title = column.getTitle(); 103 | System.out.println(" title: " + title); 104 | 105 | Integer width = column.getWidth(); 106 | System.out.println(" width: " + width); 107 | 108 | Boolean hidden = column.getHidden(); 109 | System.out.println(" hidden: " + hidden); 110 | 111 | System.out.println(); 112 | } 113 | } 114 | else { 115 | System.out.println("Request succeeded, but the response doesn't include a list of view entries."); 116 | } 117 | } 118 | catch (ApiException e) { 119 | System.err.println("Exception when calling ViewDesignApi#folderDatabaseApiDataCollectionsNameViewNameDesignGet"); 120 | String body = e.getResponseBody(); 121 | if (body != null) { 122 | System.err.println("Response from server ..."); 123 | System.err.println(body); 124 | } 125 | else { 126 | e.printStackTrace(); 127 | } 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /client-samples/mail/nodejs/README.md: -------------------------------------------------------------------------------- 1 | 15 | 16 | # Node.js samples using the DAS Mail API 17 | Sample code showing use of Domino Access Services (DAS) with Swagger 18 | generated client code. You can use this code to test mail API client 19 | code generated by 20 | [Swagger Codegen](https://github.com/swagger-api/swagger-codegen). 21 | 22 | ### Prerequisites 23 | - A Domino server with the mail API installed and enabled. 24 | - A Node.js runtime environment. 25 | - A Node.js package generated from **mail.yaml**. For example, 26 | you can use the [online Swagger editor](http://editor2.swagger.io) 27 | to import **mail.yaml** and then generate a "Javascript" client. 28 | 29 | # Instructions 30 | These instructions show how to install and run [messagelisttest.js](messagelisttest.js). 31 | To run a different mail API client sample, follow these same instructions 32 | and substitute file names where appropriate. 33 | 34 | First create a root folder and two sub-folders as shown below: 35 | 36 | ``` 37 | /tests 38 | /tests/ibm_domino_mail_api 39 | /tests/messagelisttest 40 | ``` 41 | 42 | The root folder name is not important. Choose a name other than 43 | **/tests** if necessary. 44 | 45 | ### Unzip the generated client code 46 | Next unzip the generated code to **/tests/ibm_domino_mail_api**. 47 | When you are finished, the contents of the folder should look 48 | something like this: 49 | 50 | ``` 51 | docs 52 | src 53 | test 54 | .swagger-codegen-ignore 55 | .travis.yml 56 | git_push.sh 57 | mocha.opts 58 | package.json 59 | README.md 60 | ``` 61 | 62 | ### Create your Node.js application 63 | Now use **npm** to initialize your Node.js application. Use a Node.js 64 | command shell to execute the following commands: 65 | 66 | ``` 67 | cd /tests/messagelisttest 68 | npm init 69 | ``` 70 | 71 | The **npm** command will prompt you for information about your 72 | application. Be sure to specify **messagelisttest.js** as the 73 | entry point. Otherwise, you can accept the default values 74 | as shown below: 75 | 76 | ``` 77 | name: (messagelisttest) 78 | version: (1.0.0) 79 | description: Domino mail API test 80 | entry point: (index.js) messagelisttest.js 81 | test command: 82 | git repository: 83 | keywords: 84 | author: 85 | license: (ISC) 86 | ``` 87 | 88 | Use **npm** to make your application dependent on **ibm_domino_mail_api** 89 | (the generated client code): 90 | 91 | ``` 92 | npm install --save ../ibm_domino_mail_api 93 | ``` 94 | 95 | Download [messagelisttest.js](messagelisttest.js) to the **/tests/messagelisttest** folder. 96 | Then open your local copy of **messagelisttest.js** in your favorite text editor 97 | and customize the following values for your environment: 98 | 99 | ```javascript 100 | // IMPORTANT: Change these values to match your test environment: 101 | // 102 | // - basePath is the base URL for your Domino server. 103 | // The mail service MUST be installed and enabled 104 | // on the server. Be sure to change the protocol to 105 | // http if your server doesn't support https. 106 | // 107 | // - username is the name of a user who has access to a 108 | // mail file on your Domino server 109 | // 110 | // - password is the user's password 111 | // 112 | // - folder is the mail file folder name relative to the Domino 113 | // data directory. Use '.' if the mail file is in the data 114 | // directory itself. 115 | // 116 | // - database is the mail file name. 117 | // 118 | var basePath = 'http://yourserver.yourorg.com'; 119 | var username = 'First Last'; 120 | var password = 'password'; 121 | var folder = 'mail'; 122 | var database = 'database.nsf'; 123 | ``` 124 | 125 | ### Run your Node.js application 126 | After saving your local changes, return to the Node.js command shell to run 127 | your application: 128 | 129 | ``` 130 | node messagelisttest 131 | ``` 132 | 133 | The following is some sample output from a successful run: 134 | 135 | ``` 136 | /tests/messagelisttest> node messagelisttest 137 | Reading inbox from dlawson.nsf ... 138 | Request succeeded. Response follows ... 139 | 140 | Message 0 141 | subject: Re: Test from Swagger UI 142 | date: 2017-03-14T17:47:09Z 143 | from: Dean Melnyk 144 | 145 | Message 1 146 | subject: Accepted: API test 147 | date: 2017-03-14T13:01:02Z 148 | from: Room 1001 149 | 150 | Message 2 151 | subject: Pi Day celebration 152 | date: 2017-03-14T12:59:07Z 153 | from: Raymond Chan 154 | 155 | Message 3 156 | subject: Accepted: API test 157 | date: 2017-03-14T12:56:22Z 158 | from: Room 1001 159 | ``` 160 | 161 | In other words, the **messagelisttest.js** application lists up to 162 | five messages in the specified inbox. You can specify a different view 163 | on the command line. The following command lists messages in the 164 | sent view: 165 | 166 | ``` 167 | node messagelisttest sent 168 | ``` 169 | 170 | The application accepts the following view names: `inbox`, `sent`, 171 | `drafts`, and `trash`. -------------------------------------------------------------------------------- /client-samples/freebusy/nodejs/README.md: -------------------------------------------------------------------------------- 1 | 15 | 16 | # Node.js samples using the DAS Freebusy API 17 | Sample code showing use of Domino Access Services (DAS) with Swagger 18 | generated client code. You can use this code to test freebusy client 19 | code generated by 20 | [Swagger Codegen](https://github.com/swagger-api/swagger-codegen). 21 | 22 | ### Prerequisites 23 | - A Domino server with the freebusy API installed and enabled. 24 | - A Node.js runtime environment. 25 | - A Node.js package generated from **freebusy.yaml**. For example, 26 | you can use the [online Swagger editor](http://editor2.swagger.io) 27 | to import **freebusy.yaml** and then generate a "Javascript" client. 28 | 29 | # Instructions 30 | These instructions show how to install and run [busytimetest.js](busytimetest.js). 31 | To run a different freebusy client sample, follow these same instructions 32 | and substitute file names where appropriate. 33 | 34 | First create a root folder and two sub-folders as shown below: 35 | 36 | ``` 37 | /tests 38 | /tests/ibm_domino_freebusy_api 39 | /tests/busytimetest 40 | ``` 41 | 42 | The root folder name is not important. Choose a name other than 43 | **/tests** if necessary. 44 | 45 | ### Unzip the generated client code 46 | Next unzip the generated code to **/tests/ibm_domino_freebusy_api**. 47 | When you are finished, the contents of the folder should look 48 | something like this: 49 | 50 | ``` 51 | docs 52 | src 53 | test 54 | .swagger-codegen-ignore 55 | .travis.yml 56 | git_push.sh 57 | mocha.opts 58 | package.json 59 | README.md 60 | ``` 61 | 62 | ### Create your Node.js application 63 | Now use **npm** to initialize your Node.js application. Use a Node.js 64 | command shell to execute the following commands: 65 | 66 | ``` 67 | cd /tests/busytimetest 68 | npm init 69 | ``` 70 | 71 | The **npm** command will prompt you for information about your 72 | application. Be sure to specify **busytimetest.js** as the 73 | entry point. Otherwise, you can accept the default values 74 | as shown below: 75 | 76 | ``` 77 | name: (busytimetest) 78 | version: (1.0.0) 79 | description: Freebusy API test 80 | entry point: (index.js) busytimetest.js 81 | test command: 82 | git repository: 83 | keywords: 84 | author: 85 | license: (ISC) 86 | ``` 87 | 88 | Use **npm** to make your application dependent on **ibm_domino_freebusy_api** 89 | (the generated client code): 90 | 91 | ``` 92 | npm install --save ../ibm_domino_freebusy_api 93 | ``` 94 | 95 | Download [busytimetest.js](busytimetest.js) to the **/tests/busytimetest** folder. 96 | Then open your local copy of **busytimetest.js** in your favorite text editor 97 | and customize the following values for your environment: 98 | 99 | ```javascript 100 | // IMPORTANT: Change these values to match your test environment: 101 | // 102 | // - basePath is the base URL for your Domino server. 103 | // The freebusy service MUST be installed and enabled 104 | // on the server. Be sure to change the protocol to 105 | // http if your sever doesn't support https. 106 | // 107 | // - username is the name of a user who has access to your 108 | // Domino server 109 | // 110 | // - password is the user's password 111 | // 112 | // - lookupName is the email address of a VALID user. Or you 113 | // can specify the lookup name on the command line. 114 | // 115 | // - btOpts.days is number of days of busy time data to return. 116 | 117 | var basePath = "https://yourserver.yourorg.com"; 118 | var username = "First Last"; 119 | var password = "password"; 120 | var lookupName = "user@yourorg.com"; 121 | var btOpts = { 122 | 'days': 7 123 | }; 124 | ``` 125 | 126 | ### Run your Node.js application 127 | After saving your local changes, return to the Node.js command shell to run 128 | your application: 129 | 130 | ``` 131 | node busytimetest.js 132 | ``` 133 | 134 | The following is some sample output from a successful run: 135 | 136 | ``` 137 | /tests/busytimetest> node busytimetest.js 138 | Requesting busytime for dmelnyk@yourorg.com ... 139 | Busytime API called successfully. Response follows ... 140 | 141 | start: 2017-02-21T17:00:00; end: 2017-02-21T18:00:00 142 | start: 2017-02-21T22:00:00; end: 2017-02-22T14:00:00 143 | start: 2017-02-22T17:00:00; end: 2017-02-22T18:00:00 144 | start: 2017-02-22T22:00:00; end: 2017-02-23T14:00:00 145 | start: 2017-02-23T17:00:00; end: 2017-02-23T18:00:00 146 | start: 2017-02-23T22:00:00; end: 2017-02-24T14:00:00 147 | start: 2017-02-24T17:00:00; end: 2017-02-24T18:00:00 148 | start: 2017-02-24T22:00:00; end: 2017-02-27T14:00:00 149 | start: 2017-02-27T17:00:00; end: 2017-02-27T18:00:00 150 | start: 2017-02-27T22:00:00; end: 2017-02-28T14:00:00 151 | ``` 152 | 153 | In other words, the **busytimetest.js** application displays a list 154 | of busy time periods for the specified user -- in this case 155 | **dmelnyk@yourorg.com**. You can also specify a different user 156 | on the command line. The following command displays 157 | busy time periods for **rchan@yourorg.com**: 158 | 159 | ``` 160 | node busytimetest.js rchan@yourorg.com 161 | ``` 162 | -------------------------------------------------------------------------------- /directory.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # © Copyright IBM Corp. 2017 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at: 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | # implied. See the License for the specific language governing 14 | # permissions and limitations under the License. 15 | # 16 | 17 | swagger: '2.0' 18 | 19 | # Document metadata 20 | info: 21 | title: IBM Domino Directory API 22 | version: "9.0.1" 23 | description: | 24 | The directory API provides access to a Domino directory. 25 | The API represents directory objects in JSON format. 26 | 27 | securityDefinitions: 28 | basic: 29 | type: basic 30 | 31 | security: 32 | - basic: [] 33 | 34 | # Tags 35 | tags: 36 | - name: lookup 37 | description: Look up names in the directory 38 | 39 | # Paths 40 | paths: 41 | # Lookup resource 42 | /api/directory/lookup: 43 | get: 44 | tags: 45 | - "lookup" 46 | summary: | 47 | Looks up a list of names in the directory. 48 | parameters: 49 | - $ref: '#/parameters/namesParam' 50 | - $ref: '#/parameters/countParam' 51 | - $ref: '#/parameters/exactParam' 52 | # Expected responses for this operation: 53 | responses: 54 | # Response code 55 | 200: 56 | description: Successful response 57 | schema: 58 | $ref: '#/definitions/lookupResponse' 59 | 400: 60 | description: | 61 | Bad request. For example, you specified an invalid parameter. 62 | schema: 63 | $ref: '#/definitions/errorResponse' 64 | 65 | # Object definitions 66 | definitions: 67 | match: 68 | type: object 69 | properties: 70 | fullName: 71 | type: string 72 | description: Full name for this match. 73 | shortName: 74 | type: string 75 | description: Short name for this match. 76 | type: 77 | type: string 78 | description: | 79 | Type of directory object for this match. Some possible values 80 | are `person`, `group`, `database`, and `certifier`. 81 | email: 82 | type: string 83 | description: Email address for this match. 84 | mailServer: 85 | type: string 86 | description: Home mail server for this match. 87 | mailFile: 88 | type: string 89 | description: Mail file for this match, relative to `mailServer`. 90 | 91 | lookupResult: 92 | type: object 93 | properties: 94 | name: 95 | type: string 96 | description: Name for this result. 97 | count: 98 | type: integer 99 | description: Number of matches in this result. 100 | available: 101 | type: integer 102 | description: | 103 | Number of matches available in the directory for this name. 104 | This may be greater than `count`. 105 | matches: 106 | type: array 107 | items: 108 | $ref: '#/definitions/match' 109 | 110 | lookupResponse: 111 | type: object 112 | properties: 113 | totalCount: 114 | type: integer 115 | description: Total number of matches included in this response. 116 | totalAvailable: 117 | type: integer 118 | description: | 119 | Total number of matches available in the directory. This may be 120 | greater than `totalCount` 121 | results: 122 | type: array 123 | items: 124 | $ref: '#/definitions/lookupResult' 125 | 126 | errorResponse: 127 | type: object 128 | properties: 129 | code: 130 | type: integer 131 | description: HTTP status code. For example, 400. 132 | text: 133 | type: string 134 | description: HTTP status text. For example, "Bad request". 135 | message: 136 | type: string 137 | description: Request specific error message. 138 | data: 139 | type: string 140 | description: | 141 | Error specific details. When present, this may include 142 | a server-side stack trace. 143 | type: 144 | type: string 145 | description: | 146 | When the type of the `data` property when present. 147 | For example, "text". 148 | 149 | # Definitions of common parameters 150 | parameters: 151 | namesParam: 152 | name: names 153 | in: query 154 | description: Comma separated list of names to look up. 155 | required: true 156 | type: string 157 | 158 | countParam: 159 | name: count 160 | in: query 161 | description: | 162 | The maximum number of matches to return for each name. If omitted, 163 | 50 is the default value for this parameter. You may not specify a value 164 | less than 0 or greater than 200. When this value is 0, the API returns 165 | the number of matches available for each name, but does not include a 166 | `matches` array. 167 | required: false 168 | type: integer 169 | 170 | exactParam: 171 | name: exactmatches 172 | in: query 173 | description: | 174 | When `true`, the API matches each name exactly. If omitted, the default 175 | value is `false`. In other words, the API returns partial matches. 176 | required: false 177 | type: boolean 178 | 179 | -------------------------------------------------------------------------------- /client-samples/data/nodejs/README.md: -------------------------------------------------------------------------------- 1 | 15 | 16 | # Node.js samples using the DAS Data API 17 | Sample code showing use of Domino Access Services (DAS) with Swagger 18 | generated client code. You can use this code to test data API client 19 | code generated by 20 | [Swagger Codegen](https://github.com/swagger-api/swagger-codegen). 21 | 22 | ### Prerequisites 23 | - A Domino server with the data API installed and enabled. 24 | - At least one server database with the data API enabled. 25 | For example, you may want to use the demo database from 26 | the XPages Extension Library (XLibExt.nsf). 27 | - A Node.js runtime environment. 28 | - A Node.js package generated from **data.yaml**. For example, 29 | you can use the [online Swagger editor](http://editor2.swagger.io) 30 | to import **data.yaml** and then generate a "Javascript" client. 31 | 32 | # Instructions 33 | These instructions show how to install and run [searchtest.js](searchtest.js). 34 | To run a different data API client sample, follow these same instructions 35 | and substitute file names where appropriate. 36 | 37 | First create a root folder and two sub-folders as shown below: 38 | 39 | ``` 40 | /tests 41 | /tests/ibm_domino_data_api 42 | /tests/searchtest 43 | ``` 44 | 45 | The root folder name is not important. Choose a name other than 46 | **/tests** if necessary. 47 | 48 | ### Unzip the generated client code 49 | Next unzip the generated code to **/tests/ibm_domino_data_api**. 50 | When you are finished, the contents of the folder should look 51 | something like this: 52 | 53 | ``` 54 | docs 55 | src 56 | test 57 | .swagger-codegen-ignore 58 | .travis.yml 59 | git_push.sh 60 | mocha.opts 61 | package.json 62 | README.md 63 | ``` 64 | 65 | ### Create your Node.js application 66 | Now use **npm** to initialize your Node.js application. Use a Node.js 67 | command shell to execute the following commands: 68 | 69 | ``` 70 | cd /tests/searchtest 71 | npm init 72 | ``` 73 | 74 | The **npm** command will prompt you for information about your 75 | application. Be sure to specify **searchtest.js** as the 76 | entry point. Otherwise, you can accept the default values 77 | as shown below: 78 | 79 | ``` 80 | name: (searchtest) 81 | version: (1.0.0) 82 | description: Data API test 83 | entry point: (index.js) searchtest.js 84 | test command: 85 | git repository: 86 | keywords: 87 | author: 88 | license: (ISC) 89 | ``` 90 | 91 | Use **npm** to make your application dependent on **ibm_domino_data_api** 92 | (the generated client code): 93 | 94 | ``` 95 | npm install --save ../ibm_domino_data_api 96 | ``` 97 | 98 | Download [searchtest.js](searchtest.js) to the **/tests/searchtest** folder. 99 | Then open your local copy of **searchtest.js** in your favorite text editor 100 | and customize the following values for your environment: 101 | 102 | ```javascript 103 | // IMPORTANT: Change these values to match your test environment: 104 | // 105 | // - basePath is the base URL for your Domino server. 106 | // The data service MUST be installed and enabled 107 | // on the server. Be sure to change the protocol to 108 | // http if your server doesn't support https. 109 | // 110 | // - username is the name of a user who has access to your 111 | // Domino server 112 | // 113 | // - password is the user's password 114 | // 115 | // - folder is the database folder name relative to the Domino 116 | // data directory. Use '.' if the database is in the data 117 | // directory itself. 118 | // 119 | // - database is the database file name. Use 'XPagesExt.nsf' 120 | // if your server has a copy of the XPages Extension Library 121 | // demo database. 122 | // 123 | 124 | var basePath = 'https://yourserver.yourorg.com'; 125 | var username = 'First Last'; 126 | var password = 'password'; 127 | var folder = '.'; 128 | var database = 'XPagesExt.nsf'; 129 | ``` 130 | 131 | ### Run your Node.js application 132 | After saving your local changes, return to the Node.js command shell to run 133 | your application: 134 | 135 | ``` 136 | node searchtest 137 | ``` 138 | 139 | The following is some sample output from a successful run: 140 | 141 | ``` 142 | /tests/searchtest> node searchtest 143 | Searching documents in database XPagesExt.nsf matching Lorem ... 144 | Document search API called successfully. Response follows ... 145 | 146 | Document 0 147 | unid: 91AD4A64E882BCF085257AB5005F3708 148 | modified: 2013-07-16T21:44:22Z 149 | href: /XPagesExt.nsf/api/data/documents/unid/91AD4A64E882BCF085257AB5005F3708 150 | 151 | Document 1 152 | unid: B653AD5CC9C9667885257AB5005F10B6 153 | modified: 2013-07-16T21:44:03Z 154 | href: /XPagesExt.nsf/api/data/documents/unid/B653AD5CC9C9667885257AB5005F10B6 155 | 156 | Document 2 157 | unid: E9B5987BA06C319585257AB5005EE592 158 | modified: 2013-07-16T21:43:40Z 159 | href: /XPagesExt.nsf/api/data/documents/unid/E9B5987BA06C319585257AB5005EE592 160 | ``` 161 | 162 | In other words, the **searchtest.js** application searches XPagesExt.nsf 163 | for documents containing "Lorem". You can specify a different search 164 | string on the command line. The following command searches for documents 165 | containing "Ipsum": 166 | 167 | ``` 168 | node searchtest Ipsum 169 | ``` 170 | -------------------------------------------------------------------------------- /client-samples/freebusy/java/client/freebusy/test/SitesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | package client.freebusy.test; 18 | 19 | import io.swagger.client.ApiClient; 20 | import io.swagger.client.ApiException; 21 | import io.swagger.client.api.SitesApi; 22 | import io.swagger.client.model.DirectoriesResponse; 23 | import io.swagger.client.model.Directory; 24 | import io.swagger.client.model.Site; 25 | import io.swagger.client.model.SitesResponse; 26 | 27 | import java.io.UnsupportedEncodingException; 28 | import java.net.URLDecoder; 29 | import java.util.List; 30 | 31 | public class SitesTest { 32 | 33 | public static void main(String[] args) throws UnsupportedEncodingException { 34 | 35 | // IMPORTANT: Change these values to match your test environment: 36 | // 37 | // - basePath is the base URL for your Domino server. 38 | // The freebusy service MUST be installed and enabled 39 | // on the server. Be sure to change the protocol to 40 | // https if necessary. 41 | // 42 | // - user is the user name for HTTP authentication 43 | // 44 | // - password is the user's HTTP password 45 | // 46 | String basePath = "http://yourserver.yourorg.com"; 47 | String user = "First Last"; 48 | String password = "password"; 49 | 50 | // Get the API instance and set the base path 51 | // of the target Domino server 52 | SitesApi sitesApi = new SitesApi(); 53 | ApiClient client = sitesApi.getApiClient(); 54 | client.setBasePath(basePath); 55 | client.setUsername(user); 56 | client.setPassword(password); 57 | 58 | DirectoriesResponse result = null; 59 | try { 60 | // Request directories 61 | System.out.println("Requesting directories ..."); 62 | result = sitesApi.apiFreebusyDirectoriesGet(); 63 | } 64 | catch (ApiException e) { 65 | System.err.println("Exception when calling SitesApi#apiFreebusyDirectoriesGet"); 66 | String body = e.getResponseBody(); 67 | if (body != null) { 68 | System.err.println("Response from server ..."); 69 | System.err.println(body); 70 | } 71 | else { 72 | e.printStackTrace(); 73 | } 74 | } 75 | 76 | String href = null; 77 | if (result != null) { 78 | // Does the response have directories? 79 | List directories = result.getDirectories(); 80 | if (directories != null) { 81 | 82 | // Dump the directories 83 | System.out.println("Directories request succeeded. Response follows ...\n"); 84 | for (int i = 0; i < directories.size(); i++) { 85 | Directory dir = directories.get(i); 86 | System.out.println("name: " + dir.getDisplayName()); 87 | 88 | if (i == 0) { 89 | href = dir.getLinks().get(0).getHref(); 90 | } 91 | } 92 | } 93 | else { 94 | 95 | // Unexpected response 96 | System.out.println("Directories request succeeded, but the response doesn't include a list of directories."); 97 | } 98 | } 99 | 100 | // Extract directory ID from href 101 | String directoryId = null; 102 | if (href != null) { 103 | String encoded = href.substring(href.lastIndexOf("/") + 1, href.length()); 104 | directoryId = URLDecoder.decode(encoded, "UTF-8"); 105 | } 106 | 107 | if (directoryId != null) { 108 | 109 | SitesResponse sitesResult = null; 110 | try { 111 | // Request directories 112 | System.out.println("\nRequesting sites for " + directoryId + " ..."); 113 | sitesResult = sitesApi.apiFreebusySitesDirectoryGet(directoryId); 114 | } 115 | catch (ApiException e) { 116 | System.err.println("Exception when calling SitesApi#apiFreebusySitesDirectoryGet"); 117 | String body = e.getResponseBody(); 118 | if (body != null) { 119 | System.err.println("Response from server ..."); 120 | System.err.println(body); 121 | } 122 | else { 123 | e.printStackTrace(); 124 | } 125 | } 126 | 127 | if (sitesResult != null) { 128 | 129 | // Does the response have sites? 130 | List sites = sitesResult.getSites(); 131 | if (sites != null) { 132 | 133 | // Dump the sites 134 | System.out.println("Sites request succeeded. Response follows ...\n"); 135 | for (int i = 0; i < sites.size(); i++) { 136 | Site site = sites.get(i); 137 | System.out.println("name: " + site.getDisplayName()); 138 | } 139 | } 140 | else { 141 | 142 | // Unexpected response 143 | System.out.println("Sites request succeeded, but the response doesn't include a list of sites."); 144 | } 145 | } 146 | } 147 | } 148 | 149 | } 150 | -------------------------------------------------------------------------------- /client-samples/mail/java/client/mail/test/MessageListTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | package client.mail.test; 18 | 19 | import io.swagger.client.ApiClient; 20 | import io.swagger.client.ApiException; 21 | import io.swagger.client.api.MessageListApi; 22 | import io.swagger.client.model.MessageListEntry; 23 | import io.swagger.client.model.MessageListResponse; 24 | import io.swagger.client.model.Person; 25 | 26 | public class MessageListTest { 27 | 28 | private MessageListApi _api; 29 | 30 | public MessageListTest(String basePath, String user, String password) { 31 | _api = new MessageListApi(); 32 | ApiClient client = _api.getApiClient(); 33 | client.setBasePath(basePath); 34 | client.setUsername(user); 35 | client.setPassword(password); 36 | } 37 | 38 | public static void main(String[] args) { 39 | 40 | // IMPORTANT: Change these values to match your test environment: 41 | // 42 | // - basePath is the base URL for your Domino server. 43 | // The mail service MUST be installed and enabled 44 | // on the server. Be sure to change the protocol to 45 | // https if necessary. 46 | // 47 | // - folder is the mail file database folder. The folder is relative 48 | // to the Domino data directory. Use "." if the mail file 49 | // is in the data directory itself. 50 | // 51 | // - database is the mail file database name. 52 | // 53 | // - user is the user name of the owner of the mail file specified by 54 | // /{folder}/{database}. 55 | // 56 | // - password is the user's password. 57 | // 58 | String basePath = "http://yourserver.yourorg.com"; 59 | String folder = "mail"; 60 | String database = "database.nsf"; 61 | String user = "First Last"; 62 | String password = "password"; 63 | 64 | // Create an instance of the test class 65 | MessageListTest test = new MessageListTest(basePath, user, password); 66 | 67 | // Read the inbox 68 | test.readInbox(folder, database); 69 | } 70 | 71 | /** 72 | * Reads the inbox and dumps it's messages to the console. 73 | * 74 | * @param folder 75 | * @param database 76 | */ 77 | private void readInbox(String folder, String database) { 78 | try { 79 | 80 | // Read the inbox 81 | System.out.println("Reading inbox from " + folder + "/" + database + " ..."); 82 | MessageListResponse result = _api.folderDatabaseApiMailInboxGet(folder, database, 83 | null, // start Specifies the starting entry. 84 | 5, // count Specifies the number of entries to return. 85 | null, // page Page number. 86 | null, // ps Page size or the number of entries to return. 87 | null, // search Returns only documents that match a full-text query. 88 | null, // searchmaxdocs Limits the number of documents returned by a full-text search. 89 | "date", // sortcolumn Returns entries sorted on a column. 90 | "descending", // sortorder Specifies the sort order. 91 | null, // keys Returns entries whose initial characters match keys. 92 | null // keysexactmatch Returns entries that match keys exactly. 93 | ); 94 | 95 | // Does the response have messages? 96 | if ( result != null && result.size() > 0 ) { 97 | 98 | // Dump the messages 99 | System.out.println("Read inbox request succeeded. Response follows ...\n"); 100 | for (int i = 0; i < result.size(); i++) { 101 | MessageListEntry message = result.get(i); 102 | System.out.println("Message " + i); 103 | System.out.println(" subject: " + message.getSubject()); 104 | System.out.println(" date: " + message.getDate()); 105 | System.out.println(" href: " + message.getHref()); 106 | 107 | Person person = message.getFrom(); 108 | if ( person != null ) { 109 | System.out.println(" from: " + person.getDisplayName()); 110 | } 111 | 112 | System.out.println(); 113 | } 114 | } 115 | else { 116 | 117 | // Unexpected response 118 | System.out.println("Read inbox request succeeded, but the response doesn't include a list of messages."); 119 | } 120 | } 121 | catch (ApiException e) { 122 | System.err.println("Exception when calling MessageListApi#folderDatabaseApiMailInboxGet"); 123 | String body = e.getResponseBody(); 124 | if (body != null) { 125 | System.err.println("Response from server ..."); 126 | System.err.println(body); 127 | } 128 | else { 129 | e.printStackTrace(); 130 | } 131 | } 132 | } 133 | 134 | } 135 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 15 | 16 | # IBM Domino Access Services API Specifications 17 | 18 | Domino Access Services (DAS) is a family of REST APIs. There are separate 19 | APIs for: 20 | 21 | - Data (since Domino 8.5.3 UP1) 22 | - Calendar (since Domino 9.0.1) 23 | - Freebusy (since Domino 9.0.1 FP10) 24 | - Mail (since Domino 9.0.1 FP10) 25 | - Directory (see [the XPages extension library](http://extlib.openntf.org)) 26 | 27 | This repository contains OpenAPI specifications for DAS APIs. 28 | Each API has a separate specification. For example, the freebusy API 29 | specification is [freebusy.yaml](freebusy.yaml). 30 | 31 | ## Recent Revisions 32 | 33 | - [README](README.md) updates for Domino 9.0.1 FP10. The mail and freebusy APIs 34 | are now included in FP10. (31-Jan-2018) 35 | - [data.yaml](data.yaml) changes for Extension Library version 901v08_01. Also added 36 | [directory.yaml](directory.yaml) spec for new directory API. (5-November-2017) 37 | - [mail.yaml](mail.yaml) changes for Extension Library version 901v08_01 (11-September-2017) 38 | - [data.yaml](data.yaml) changes for Domino 9.0.1 FP9 (22-August-2017) 39 | - [wiki page](https://github.com/OpenNTF/das-api-specs/wiki/Config-settings-to-disable-individual-DAS-resources) 40 | describing how to disable selected DAS resources (22-August-2017) 41 | 42 | ## Uses 43 | 44 | You can use these OpenAPI specifications with a broad range of Swagger tools. 45 | For example: 46 | 47 | - Use [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) to 48 | generate client libraries for most popular languages and frameworks. 49 | For detailed instructions, see the 50 | [Generating client code](https://github.com/OpenNTF/das-api-specs/wiki/Generating-client-code) 51 | article. 52 | 53 | - Use [Swagger UI](https://github.com/swagger-api/swagger-ui) to view API 54 | documentation. When you deploy Swagger UI to your own 55 | Domino server, you can even try ad-hoc API requests 56 | without writing a line of client code. For deployment instructions, see 57 | the [Swagger UI on Domino](https://github.com/OpenNTF/das-api-specs/wiki/Swagger-UI-on-Domino) 58 | article. 59 | 60 | For a quick demo of the Swagger tools and DAS, see the [REST API Demonstration](https://youtu.be/DMatdeFf2HU) 61 | video on YouTube. 62 | 63 | ## Sample Client Code 64 | 65 | This repository also includes DAS client samples. These samples 66 | demonstrate how to use DAS APIs with Swagger generated client libraries. 67 | (*NOTE:* This repository does not include the generated code.) 68 | 69 | The samples are not intended to be full-featured applications. Rather, 70 | the emphasis is on hands-on learning. You can quickly customize each 71 | sample for your own Domino server, learn from working code, and gradually 72 | tackle your own application. 73 | 74 | To get started with the sample code, see the [DAS client samples](client-samples) 75 | page. 76 | 77 | ## Specifications by Version 78 | 79 | Unless otherwise noted, the OpenAPI specifications in this repository are 80 | for the latest versions of Domino and the extension library. Since you 81 | may be using an earlier version of an API, we intend to archive earlier 82 | versions of the OpenAPI specifications in this repository. 83 | 84 | Currently, this repository includes the following versions of each 85 | specification: 86 | 87 | | Release | Specifications | 88 | | ------------------------------- | -------------- | 89 | | **Domino 9.0.1 - 9.0.1 FP7** | [calendar.yaml](specs-by-version/v901/calendar.yaml), [data.yaml](specs-by-version/v901/data.yaml) | 90 | | **Extension Library 901v00_17** | [calendar.yaml](calendar.yaml), [data.yaml](specs-by-version/x901v00_17/data.yaml), [freebusy.yaml](freebusy.yaml), [mail.yaml](specs-by-version/x901v00_17/mail.yaml) | 91 | | **Domino 9.0.1 FP8** | [calendar.yaml](calendar.yaml), [data.yaml](specs-by-version/v901fp8/data.yaml) | 92 | | **Extension Library 901v08_01** | [calendar.yaml](calendar.yaml), [data.yaml](specs-by-version/v901fp9/data.yaml), [freebusy.yaml](freebusy.yaml), [mail.yaml](mail.yaml) | 93 | | **Domino 9.0.1 FP9** | [calendar.yaml](calendar.yaml), [data.yaml](specs-by-version/v901fp9/data.yaml) | 94 | | **Extension Library 901v09_01** | [calendar.yaml](calendar.yaml), [data.yaml](specs-by-version/v901fp9/data.yaml), [freebusy.yaml](freebusy.yaml), [mail.yaml](mail.yaml) | 95 | | **Extension Library 901v09_02** | [calendar.yaml](calendar.yaml), [data.yaml](data.yaml), [directory.yaml](directory.yaml), [freebusy.yaml](freebusy.yaml), [mail.yaml](mail.yaml) | 96 | | **Domino 9.0.1 FP10** | [calendar.yaml](calendar.yaml), [data.yaml](data.yaml), [freebusy.yaml](freebusy.yaml), [mail.yaml](mail.yaml) | 97 | 98 | ## Contributions 99 | 100 | We hope you find this repository useful and encourage you contribute 101 | back when possible. For example: 102 | 103 | - If you find a problem with one of the OpenAPI specifications, 104 | report the issue. If you are feeling ambitious, fix the 105 | problem yourself and create a pull request. 106 | 107 | - If you find a problem with one of the client samples, create 108 | a pull request and/or report the issue. 109 | 110 | - Are you an expert in Android, C#, PHP or Ruby? If you don't find 111 | a client sample for your favorite language or platform, 112 | write your own sample and create a pull request. 113 | 114 | ## References 115 | 116 | For more information about Domino Access Services, see 117 | [the DAS topic](https://www-10.lotus.com/ldd/ddwiki.nsf/xpAPIViewer.xsp?lookupName=IBM+Domino+Access+Services+9.0.1#action=openDocument&content=catcontent&ct=api) 118 | on the IBM Notes and Domino Application Development wiki. For DAS APIs 119 | added by the XPages Extension Library, see 120 | [the extlib project on OpenNTF](https://extlib.openntf.org/). 121 | 122 | For more about the Swagger framework see [swagger.io](http://swagger.io/) 123 | and the [Swagger repositories](https://github.com/swagger-api) 124 | on GitHub. 125 | 126 | For more about OpenAPI, see the [OpenAPI Specification](https://github.com/OAI/OpenAPI-Specification). 127 | 128 | ## OpenNTF 129 | 130 | This project is an OpenNTF project, and is available under the Apache 131 | Licence V2.0. All other aspects of the project, including contributions, 132 | defect reports, discussions, feature requests and reviews are subject 133 | to the OpenNTF Terms of Use - available at 134 | http://openntf.org/Internal/home.nsf/dx/Terms_of_Use. 135 | -------------------------------------------------------------------------------- /client-samples/mail/java/client/mail/test/DelegateTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | package client.mail.test; 18 | 19 | import io.swagger.client.ApiClient; 20 | import io.swagger.client.ApiException; 21 | import io.swagger.client.api.DelegateApi; 22 | import io.swagger.client.model.Access; 23 | import io.swagger.client.model.Delegate; 24 | 25 | public class DelegateTest { 26 | 27 | private static final String DELEGATE_NAME = "Test Delegate/Your Org"; 28 | 29 | private DelegateApi _api; 30 | 31 | public DelegateTest(String basePath, String user, String password) { 32 | _api = new DelegateApi(); 33 | ApiClient client = _api.getApiClient(); 34 | client.setBasePath(basePath); 35 | client.setUsername(user); 36 | client.setPassword(password); 37 | } 38 | 39 | public static void main(String[] args) { 40 | 41 | // IMPORTANT: Change these values to match your test environment: 42 | // 43 | // - basePath is the base URL for your Domino server. 44 | // The mail service MUST be installed and enabled 45 | // on the server. Be sure to change the protocol to 46 | // https if necessary. 47 | // 48 | // - folder is the mail file database folder. The folder is relative 49 | // to the Domino data directory. Use "." if the mail file 50 | // is in the data directory itself. 51 | // 52 | // - database is the mail file database name. 53 | // 54 | // - user is the user name of the owner of the mail file specified by 55 | // /{folder}/{database}. 56 | // 57 | // - password is the user's password. 58 | // 59 | String basePath = "http://yourserver.yourorg.com"; 60 | String folder = "mail"; 61 | String database = "database.nsf"; 62 | String user = "First Last"; 63 | String password = "password"; 64 | 65 | // Create an instance of the test class 66 | 67 | DelegateTest test = new DelegateTest(basePath, user, password); 68 | 69 | // Create a delegate with create access (but not edit access) 70 | 71 | Access access = new Access().what("mail").create(true); 72 | Delegate delegate = new Delegate().name(DELEGATE_NAME).access(access); 73 | boolean created = test.createDelegate(folder, database, delegate); 74 | 75 | // Stop now if we didn't create the delegate 76 | 77 | if ( !created ) { 78 | return; 79 | } 80 | 81 | // Read and verify the delegate 82 | 83 | delegate = test.readDelegate(folder, database, DELEGATE_NAME); 84 | if ( delegate != null ) { 85 | boolean valid = true; 86 | 87 | if ( ! "mail".equals(delegate.getAccess().getWhat()) ) { 88 | System.err.println("Unexpected access type: " + delegate.getAccess().getWhat()); 89 | valid = false; 90 | } 91 | 92 | if ( delegate.getAccess().getEdit() ) { 93 | System.err.println("Unexpected edit access. Should be false."); 94 | valid = false; 95 | } 96 | 97 | if ( ! delegate.getAccess().getCreate() ) { 98 | System.err.println("Unexpected create access. Should be true."); 99 | valid = false; 100 | } 101 | 102 | if ( valid ) { 103 | System.out.println("All delegate object values are as expected."); 104 | } 105 | System.out.println(); 106 | } 107 | 108 | // Delete the delegate 109 | 110 | test.deleteDelegate(folder, database, DELEGATE_NAME); 111 | } 112 | 113 | /** 114 | * Creates a delegate. 115 | * 116 | * @param folder 117 | * @param database 118 | */ 119 | private boolean createDelegate(String folder, String database, Delegate delegate) { 120 | boolean created = false; 121 | 122 | try { 123 | 124 | // Create the delegate 125 | System.out.println("Creating delegate " + delegate.getName() + " in " + folder + "/" + database + " ..."); 126 | _api.folderDatabaseApiMailDelegatesPost(folder, database, delegate); 127 | 128 | System.out.println("Create delegate request succeeded.\n"); 129 | created = true; 130 | } 131 | catch (ApiException e) { 132 | System.err.println("Exception when calling DelegateApi#folderDatabaseApiMailDelegatesPost"); 133 | String body = e.getResponseBody(); 134 | if (body != null) { 135 | System.err.println("Response from server ..."); 136 | System.err.println(body); 137 | } 138 | else { 139 | e.printStackTrace(); 140 | } 141 | } 142 | 143 | return created; 144 | } 145 | 146 | /** 147 | * Reads a delegate. 148 | * 149 | * @param folder 150 | * @param database 151 | */ 152 | private Delegate readDelegate(String folder, String database, String name) { 153 | Delegate delegate = null; 154 | 155 | try { 156 | 157 | // Read the delegate 158 | System.out.println("Reading delegate " + name + " from " + folder + "/" + database + " ..."); 159 | delegate = _api.folderDatabaseApiMailDelegatesNameGet(folder, database, name); 160 | 161 | // Does the response have a delegate? 162 | if ( delegate == null ) { 163 | 164 | // Unexpected response 165 | System.out.println("Read delegate request succeeded, but the response doesn't include delegate information."); 166 | } 167 | } 168 | catch (ApiException e) { 169 | System.err.println("Exception when calling DelegateApi#folderDatabaseApiMailDelegatesNameGet"); 170 | String body = e.getResponseBody(); 171 | if (body != null) { 172 | System.err.println("Response from server ..."); 173 | System.err.println(body); 174 | } 175 | else { 176 | e.printStackTrace(); 177 | } 178 | } 179 | 180 | return delegate; 181 | } 182 | 183 | /** 184 | * Deletes a delegate. 185 | * 186 | * @param folder 187 | * @param database 188 | */ 189 | private void deleteDelegate(String folder, String database, String name) { 190 | 191 | try { 192 | 193 | // Delete the delegate 194 | System.out.println("Deleting delegate " + name + " from " + folder + "/" + database + " ..."); 195 | _api.folderDatabaseApiMailDelegatesNameDelete(folder, database, name); 196 | 197 | } 198 | catch (ApiException e) { 199 | System.err.println("Exception when calling DelegateApi#folderDatabaseApiMailDelegatesNameDelete"); 200 | String body = e.getResponseBody(); 201 | if (body != null) { 202 | System.err.println("Response from server ..."); 203 | System.err.println(body); 204 | } 205 | else { 206 | e.printStackTrace(); 207 | } 208 | } 209 | } 210 | 211 | } 212 | -------------------------------------------------------------------------------- /client-samples/mail/java/client/mail/test/MessageTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | package client.mail.test; 18 | 19 | import io.swagger.client.ApiClient; 20 | import io.swagger.client.ApiException; 21 | import io.swagger.client.ApiResponse; 22 | import io.swagger.client.api.MessageApi; 23 | import io.swagger.client.model.Message; 24 | import io.swagger.client.model.MessagePart; 25 | import io.swagger.client.model.Person; 26 | 27 | import java.util.List; 28 | import java.util.Map; 29 | import java.util.Set; 30 | 31 | public class MessageTest { 32 | 33 | private static final String MIME_BOUNDARY = "abcdefg"; 34 | 35 | private MessageApi _api; 36 | 37 | public MessageTest(String basePath, String user, String password) { 38 | _api = new MessageApi(); 39 | ApiClient client = _api.getApiClient(); 40 | client.setBasePath(basePath); 41 | client.setUsername(user); 42 | client.setPassword(password); 43 | } 44 | 45 | public static void main(String[] args) { 46 | 47 | // IMPORTANT: Change these values to match your test environment: 48 | // 49 | // - basePath is the base URL for your Domino server. 50 | // The mail service MUST be installed and enabled 51 | // on the server. Be sure to change the protocol to 52 | // https if necessary. 53 | // 54 | // - folder is the mail file database folder. The folder is relative 55 | // to the Domino data directory. Use "." if the mail file 56 | // is in the data directory itself. 57 | // 58 | // - database is the mail file database name. 59 | // 60 | // - user is the user name of the owner of the mail file specified by 61 | // /{folder}/{database}. 62 | // 63 | // - password is the user's password. 64 | // 65 | // - sendTo is the email address of a recipient 66 | // 67 | String basePath = "http://yourserver.yourorg.com"; 68 | String folder = "mail"; 69 | String database = "database.nsf"; 70 | String user = "First Last"; 71 | String password = "password"; 72 | String sendTo = "recipient@yourorg.com"; 73 | 74 | // Create an instance of the test class 75 | 76 | MessageTest test = new MessageTest(basePath, user, password); 77 | 78 | // Create a message 79 | 80 | Message message = new Message(); 81 | message.setSubject("Test message from Swagger generated Java client code"); 82 | 83 | Person person = new Person(); 84 | person.setEmail(sendTo); 85 | message.addToItem(person); 86 | 87 | MessagePart part = new MessagePart(); 88 | part.setContentType("multipart/alternative; Boundary=" + MIME_BOUNDARY); 89 | message.addContentItem(part); 90 | 91 | part = new MessagePart(); 92 | part.setContentType("text/plain"); 93 | part.setBoundary("--" + MIME_BOUNDARY); 94 | part.setData("This is a test."); 95 | message.addContentItem(part); 96 | 97 | part = new MessagePart(); 98 | part.setContentType("text/html"); 99 | part.setBoundary("--" + MIME_BOUNDARY); 100 | part.setData("This is a test.

This is only a test!"); 101 | message.addContentItem(part); 102 | 103 | // Send the message 104 | 105 | String unid = test.sendMessage(folder, database, message); 106 | 107 | // Read the message 108 | 109 | if ( unid != null ) { 110 | test.readMessage(folder, database, unid); 111 | } 112 | } 113 | 114 | /** 115 | * Sends a message. 116 | * 117 | * @param folder 118 | * @param database 119 | */ 120 | private String sendMessage(String folder, String database, Message message) { 121 | String unid = null; 122 | 123 | try { 124 | 125 | // Send the message 126 | System.out.println("Sending message from " + folder + "/" + database + " ..."); 127 | ApiResponse result = _api.folderDatabaseApiMailOutboxPostWithHttpInfo(folder, database, message); 128 | 129 | // Extract the Location header 130 | String location = null; 131 | Map> headers = result.getHeaders(); 132 | if (headers != null) { 133 | Set keys = headers.keySet(); 134 | for (String key : keys) { 135 | if (key.equalsIgnoreCase("Location")) { 136 | location = headers.get(key).get(0); 137 | break; 138 | } 139 | } 140 | } 141 | 142 | // Extract the UID from the location 143 | if (location != null) { 144 | // Dump the Location header 145 | System.out.println("Send message request succeeded. Location is " + location); 146 | 147 | int index = location.lastIndexOf('/'); 148 | if (index != -1) { 149 | unid = location.substring(index + 1, location.length()); 150 | } 151 | } 152 | else { 153 | // Unexpected response 154 | System.out.println("Send message request succeeded, but the response doesn't include a Location header."); 155 | } 156 | 157 | System.out.println(); 158 | } 159 | catch (ApiException e) { 160 | System.err.println("Exception when calling MessageApi#folderDatabaseApiMailOutboxPostWithHttpInfo"); 161 | String body = e.getResponseBody(); 162 | if (body != null) { 163 | System.err.println("Response from server ..."); 164 | System.err.println(body); 165 | } 166 | else { 167 | e.printStackTrace(); 168 | } 169 | } 170 | 171 | return unid; 172 | } 173 | 174 | /** 175 | * Reads a message and dumps its contents. 176 | * 177 | * @param folder 178 | * @param database 179 | * @param unid 180 | */ 181 | private void readMessage(String folder, String database, String unid) { 182 | 183 | try { 184 | 185 | // Send the message 186 | System.out.println("Reading message " + unid + " from " + folder + "/" + database + " ..."); 187 | Message message = _api.folderDatabaseApiMailMessagesUnidGet(folder, database, unid, null, null, false); 188 | 189 | if ( message != null ) { 190 | 191 | // Successful response 192 | System.out.println("Read message request succeeded. Response follows ..."); 193 | 194 | System.out.println(" subject: " + message.getSubject()); 195 | System.out.println(" date: " + message.getDate()); 196 | System.out.println(); 197 | 198 | List parts = message.getContent(); 199 | for ( MessagePart part : parts ) { 200 | String contentType = part.getContentType(); 201 | if ( contentType != null && contentType.startsWith("text") ) { 202 | System.out.println(" contentType: " + contentType); 203 | System.out.println(" data: " + part.getData()); 204 | System.out.println(); 205 | } 206 | } 207 | } 208 | else { 209 | // Unexpected response 210 | System.out.println("Read message request succeeded, but the response doesn't include a message."); 211 | } 212 | } 213 | catch (ApiException e) { 214 | System.err.println("Exception when calling MessageApi#folderDatabaseApiMailMessagesUnidGet"); 215 | String body = e.getResponseBody(); 216 | if (body != null) { 217 | System.err.println("Response from server ..."); 218 | System.err.println(body); 219 | } 220 | else { 221 | e.printStackTrace(); 222 | } 223 | } 224 | } 225 | 226 | } 227 | -------------------------------------------------------------------------------- /freebusy.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # © Copyright IBM Corp. 2017 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at: 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | # implied. See the License for the specific language governing 14 | # permissions and limitations under the License. 15 | # 16 | 17 | swagger: '2.0' 18 | 19 | # Document metadata 20 | info: 21 | title: IBM Domino Freebusy API 22 | version: "9.0.1" 23 | description: | 24 | The freebusy API is used to: 25 | - Get busy time for a given person or room. 26 | - Get a list of available rooms for a given time. 27 | - Get a list of sites in a directory. 28 | 29 | securityDefinitions: 30 | basic: 31 | type: basic 32 | 33 | security: 34 | - basic: [] 35 | 36 | # Tags 37 | tags: 38 | - name: busytime 39 | description: Get busy time 40 | - name: freerooms 41 | description: Get a list of available rooms 42 | - name: sites 43 | description: Get a list of sites 44 | 45 | # Paths 46 | paths: 47 | # Busy time resource 48 | /api/freebusy/busytime: 49 | get: 50 | tags: 51 | - "busytime" 52 | summary: | 53 | Gets busy time for a given person or room. 54 | parameters: 55 | - 56 | name: name 57 | in: query 58 | description: Name or email address of the person (or room). 59 | required: true 60 | type: string 61 | - 62 | name: format 63 | in: query 64 | description: | 65 | The desired format of the response. If you omit this 66 | parameter, the response is in JSON format. For iCalendar 67 | format, specify `format=icalendar`. 68 | required: false 69 | type: string 70 | - 71 | name: since 72 | in: query 73 | description: | 74 | The start date in UTC for the busy time data (for example, 75 | `since=2017-09-01T13:00:00Z`). If you omit this 76 | parameter, the default start date is the time of the 77 | request minus 30 minutes. 78 | required: false 79 | type: string 80 | - 81 | name: before 82 | in: query 83 | description: | 84 | The end date in UTC for the busy time data (for example, 85 | `before=2017-10-01T13:00:00Z`). If you omit both 86 | the `before` and `days` parameters, the default end 87 | date is 30 days after the start date. 88 | required: false 89 | type: string 90 | - 91 | name: days 92 | in: query 93 | description: | 94 | The requested number of days of busy time data. 95 | The `before` and `days` parameters are mutually 96 | exclusive. 97 | required: false 98 | type: integer 99 | # Expected responses for this operation: 100 | responses: 101 | # Response code 102 | 200: 103 | description: Successful response 104 | schema: 105 | $ref: '#/definitions/busyTimeResponse' 106 | 400: 107 | description: | 108 | Bad request. For example, the person or room specified by 109 | the `name` parameter was not found. 110 | schema: 111 | $ref: '#/definitions/errorResponse' 112 | 113 | # Free rooms resource 114 | /api/freebusy/freerooms: 115 | get: 116 | tags: 117 | - "freerooms" 118 | summary: | 119 | Gets a list of available rooms for a given time. 120 | parameters: 121 | - 122 | name: site 123 | in: query 124 | description: | 125 | The site to search. If the site includes spaces or other 126 | special characters, it must be URL encoded. 127 | required: true 128 | type: string 129 | - 130 | name: start 131 | in: query 132 | description: | 133 | The start date in UTC for the free rooms search 134 | (for example, `start=2017-09-01T13:00:00Z`). 135 | required: true 136 | type: string 137 | - 138 | name: end 139 | in: query 140 | description: | 141 | The end date in UTC for the free rooms search 142 | (for example, `end=2017-09-01T14:00:00Z`). 143 | required: true 144 | type: string 145 | - 146 | name: capacity 147 | in: query 148 | description: | 149 | The minimum required room capacity. If you omit 150 | this parameter, the default capacity is 5. 151 | required: false 152 | type: integer 153 | # Expected responses for this operation: 154 | responses: 155 | # Response code 156 | 200: 157 | description: Successful response 158 | schema: 159 | $ref: '#/definitions/freeRoomsResponse' 160 | 400: 161 | description: | 162 | Bad request. For example, a required parameter was not 163 | included. 164 | schema: 165 | $ref: '#/definitions/errorResponse' 166 | 167 | # Directories resource 168 | /api/freebusy/directories: 169 | get: 170 | tags: 171 | - "sites" 172 | summary: | 173 | Gets a list of directories. 174 | responses: 175 | 200: 176 | description: Successful response 177 | schema: 178 | $ref: '#/definitions/directoriesResponse' 179 | 180 | # Sites resource 181 | /api/freebusy/sites/{directory}: 182 | get: 183 | tags: 184 | - "sites" 185 | summary: | 186 | Gets a list of sites in a directory. 187 | parameters: 188 | - 189 | name: directory 190 | in: path 191 | description: | 192 | The directory. You can get a list of directories 193 | from the directories resource. 194 | required: true 195 | type: string 196 | responses: 197 | 200: 198 | description: Successful response 199 | schema: 200 | $ref: '#/definitions/sitesResponse' 201 | 202 | # Object definitions 203 | definitions: 204 | exDateTime: 205 | type: object 206 | properties: 207 | date: 208 | type: string 209 | time: 210 | type: string 211 | utc: 212 | type: boolean 213 | 214 | exDateTimeRange: 215 | type: object 216 | properties: 217 | start: 218 | $ref: '#/definitions/exDateTime' 219 | end: 220 | $ref: '#/definitions/exDateTime' 221 | 222 | room: 223 | type: object 224 | properties: 225 | displayName: 226 | type: string 227 | distinguishedName: 228 | type: string 229 | email: 230 | type: string 231 | capacity: 232 | type: integer 233 | 234 | site: 235 | type: object 236 | properties: 237 | displayName: 238 | type: string 239 | 240 | link: 241 | type: object 242 | properties: 243 | rel: 244 | type: string 245 | href: 246 | type: string 247 | 248 | directory: 249 | type: object 250 | properties: 251 | links: 252 | type: array 253 | items: 254 | $ref: '#/definitions/link' 255 | displayName: 256 | type: string 257 | 258 | busyTimeResponse: 259 | type: object 260 | properties: 261 | start: 262 | $ref: '#/definitions/exDateTime' 263 | end: 264 | $ref: '#/definitions/exDateTime' 265 | busyTimes: 266 | type: array 267 | items: 268 | $ref: '#/definitions/exDateTimeRange' 269 | 270 | freeRoomsResponse: 271 | type: object 272 | properties: 273 | rooms: 274 | type: array 275 | items: 276 | $ref: '#/definitions/room' 277 | 278 | directoriesResponse: 279 | type: object 280 | properties: 281 | directories: 282 | type: array 283 | items: 284 | $ref: '#/definitions/directory' 285 | 286 | sitesResponse: 287 | type: object 288 | properties: 289 | sites: 290 | type: array 291 | items: 292 | $ref: '#/definitions/site' 293 | 294 | errorResponse: 295 | type: object 296 | properties: 297 | code: 298 | type: integer 299 | description: HTTP status code. For example, 400. 300 | text: 301 | type: string 302 | description: HTTP status text. For example, "Bad request". 303 | message: 304 | type: string 305 | description: Request specific error message. For example, "Name not found". 306 | data: 307 | type: string 308 | description: | 309 | Error specific details. When present, this may include 310 | a server-side stack trace. 311 | type: 312 | type: string 313 | description: | 314 | When the type of the `data` property when present. 315 | For example, "text". -------------------------------------------------------------------------------- /client-samples/mail/java/client/mail/test/MailFolderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | package client.mail.test; 18 | 19 | import io.swagger.client.ApiClient; 20 | import io.swagger.client.ApiException; 21 | import io.swagger.client.ApiResponse; 22 | import io.swagger.client.api.FolderApi; 23 | import io.swagger.client.api.FolderListApi; 24 | import io.swagger.client.model.FolderListResponse; 25 | import io.swagger.client.model.MailFolder; 26 | 27 | import java.util.List; 28 | import java.util.Map; 29 | import java.util.Set; 30 | 31 | public class MailFolderTest { 32 | 33 | private FolderListApi _folderListApi; 34 | private FolderApi _folderApi; 35 | 36 | public MailFolderTest(String basePath, String user, String password) { 37 | _folderListApi = new FolderListApi(); 38 | ApiClient client = _folderListApi.getApiClient(); 39 | client.setBasePath(basePath); 40 | client.setUsername(user); 41 | client.setPassword(password); 42 | 43 | _folderApi = new FolderApi(); 44 | } 45 | 46 | public static void main(String[] args) { 47 | 48 | // IMPORTANT: Change these values to match your test environment: 49 | // 50 | // - basePath is the base URL for your Domino server. 51 | // The mail service MUST be installed and enabled 52 | // on the server. Be sure to change the protocol to 53 | // https if necessary. 54 | // 55 | // - folder is the mail file database folder. The folder is relative 56 | // to the Domino data directory. Use "." if the mail file 57 | // is in the data directory itself. 58 | // 59 | // - database is the mail file database name. 60 | // 61 | // - user is the user name of the owner of the mail file specified by 62 | // /{folder}/{database}. 63 | // 64 | // - password is the user's password. 65 | // 66 | String basePath = "http://yourserver.yourorg.com"; 67 | String folder = "mail"; 68 | String database = "database.nsf"; 69 | String user = "First Last"; 70 | String password = "password"; 71 | String testFolderName = "Folder API Test"; 72 | 73 | // Create an instance of the test class 74 | 75 | MailFolderTest test = new MailFolderTest(basePath, user, password); 76 | 77 | // Read the list of folders 78 | 79 | List folders = test.readFolderList(folder, database); 80 | if ( folders == null ) { 81 | System.err.println("Cannot read existing folders. Stopping tests."); 82 | return; 83 | } 84 | 85 | // Make sure test folder doesn't already exist 86 | 87 | for ( MailFolder mailFolder : folders ) { 88 | if ( testFolderName.equalsIgnoreCase(mailFolder.getName())) { 89 | System.err.println("Test folder already exists: " + testFolderName); 90 | System.err.println("Stopping tests. Resolve the conflict and try again."); 91 | return; 92 | } 93 | } 94 | 95 | // Create a new folder 96 | 97 | String folderUnid = test.createFolder(folder, database, testFolderName); 98 | if ( folderUnid != null ) { 99 | 100 | // TODO: Add tests for adding and removing messages 101 | 102 | // Delete the folder 103 | 104 | test.deleteFolder(folder, database, folderUnid); 105 | } 106 | } 107 | 108 | /** 109 | * Reads a list of mail folders. 110 | * 111 | * @param folder 112 | * @param database 113 | */ 114 | private List readFolderList(String folder, String database) { 115 | List folders = null; 116 | 117 | try { 118 | 119 | // Read the folder list 120 | System.out.println("Reading folder list from " + folder + "/" + database + " ..."); 121 | FolderListResponse response = _folderListApi.folderDatabaseApiMailFoldersGet(folder, database); 122 | 123 | // Does the response have a folder list? 124 | if ( response != null ) { 125 | folders = response; 126 | 127 | // Dump the quota 128 | System.out.println("Read folder list request succeeded. Number of folders: " + folders.size() + "\n"); 129 | } 130 | else { 131 | 132 | // Unexpected response 133 | System.out.println("Read folder list request succeeded, but the response doesn't include a list of folders."); 134 | } 135 | } 136 | catch (ApiException e) { 137 | System.err.println("Exception when calling FolderListApi#folderDatabaseApiMailFoldersGet"); 138 | String body = e.getResponseBody(); 139 | if (body != null) { 140 | System.err.println("Response from server ..."); 141 | System.err.println(body); 142 | } 143 | else { 144 | e.printStackTrace(); 145 | } 146 | } 147 | 148 | return folders; 149 | } 150 | 151 | /** 152 | * Creates a mail folder. 153 | * 154 | * @param folder 155 | * @param database 156 | * @param mailFolderName 157 | * @return 158 | */ 159 | private String createFolder(String folder, String database, String mailFolderName) { 160 | String unid = null; 161 | 162 | try { 163 | MailFolder mailFolder = new MailFolder(); 164 | mailFolder.setName(mailFolderName); 165 | 166 | // Read the folder list 167 | System.out.println("Creating folder " + mailFolderName + " ..."); 168 | ApiResponse response = _folderApi.folderDatabaseApiMailFoldersPostWithHttpInfo(folder, database, mailFolder); 169 | 170 | // Extract the Location header 171 | String location = null; 172 | Map> headers = response.getHeaders(); 173 | if (headers != null) { 174 | Set keys = headers.keySet(); 175 | for (String key : keys) { 176 | if (key.equalsIgnoreCase("Location")) { 177 | location = headers.get(key).get(0); 178 | break; 179 | } 180 | } 181 | } 182 | 183 | // Extract the UID from the location 184 | if (location != null) { 185 | // Dump the Location header 186 | System.out.println("Create folder request succeeded. Location is " + location); 187 | 188 | int index = location.lastIndexOf('/'); 189 | if (index != -1) { 190 | unid = location.substring(index + 1, location.length()); 191 | } 192 | } 193 | else { 194 | // Unexpected response 195 | System.out.println("Create folder request succeeded, but the response doesn't include a Location header."); 196 | } 197 | 198 | System.out.println(); 199 | } 200 | catch (ApiException e) { 201 | System.err.println("Exception when calling FolderApi#folderDatabaseApiMailFoldersPostWithHttpInfo"); 202 | String body = e.getResponseBody(); 203 | if (body != null) { 204 | System.err.println("Response from server ..."); 205 | System.err.println(body); 206 | } 207 | else { 208 | e.printStackTrace(); 209 | } 210 | } 211 | 212 | return unid; 213 | } 214 | 215 | /** 216 | * Deletes a mail folder. 217 | * 218 | * @param folder 219 | * @param database 220 | * @param unid 221 | */ 222 | private void deleteFolder(String folder, String database, String unid) { 223 | 224 | try { 225 | 226 | // Delete the folder 227 | System.out.println("Deleting folder " + unid + " from " + folder + "/" + database + " ..."); 228 | _folderApi.folderDatabaseApiMailFoldersUnidDelete(folder, database, unid); 229 | 230 | } 231 | catch (ApiException e) { 232 | System.err.println("Exception when calling FolderApi#folderDatabaseApiMailFoldersUnidDelete"); 233 | String body = e.getResponseBody(); 234 | if (body != null) { 235 | System.err.println("Response from server ..."); 236 | System.err.println(body); 237 | } 238 | else { 239 | e.printStackTrace(); 240 | } 241 | } 242 | } 243 | } 244 | -------------------------------------------------------------------------------- /client-samples/freebusy/java/README.md: -------------------------------------------------------------------------------- 1 | 15 | 16 | # Java samples using the DAS Freebusy API 17 | Sample code showing use of Domino Access Services (DAS) with Swagger 18 | generated client code. You can use this code to test freebusy API 19 | client code generated by 20 | [Swagger Codegen](https://github.com/swagger-api/swagger-codegen). 21 | 22 | ### Prerequisites 23 | - A Domino server with the freebusy API installed and enabled. 24 | - A Java development kit (JDK). Java 7 is the minimum required 25 | version. 26 | - Apache Maven to build the Java code and automatically manage 27 | dependencies. 28 | - A Java client package generated from **freebusy.yaml**. For example, 29 | you can use the [online Swagger editor](http://editor2.swagger.io) 30 | to import **freebusy.yaml** and then generate a "Java" client. 31 | (*Note:* This repository does not include the generated code.) 32 | 33 | ### Required JARs 34 | The generated client package includes a Maven project object module 35 | (**pom.xml**) identifying several required JARs. Therefore, we 36 | recommend you use Maven to automatically build 37 | the project and manage its dependencies. If you choose not to 38 | use Maven, the list of required JARs is as currently follows: 39 | 40 | - gson-2.6.2.jar 41 | - joda-time-2.9.3.jar 42 | - logging-interceptor-2.7.5.jar 43 | - okhttp-2.7.5.jar 44 | - okio-1.6.0.jar 45 | - swagger-annotations-1.5.9.jar 46 | 47 | This list depends on the version of Swagger Codegen and is subject 48 | to change without notice. (In other words, you really should use 49 | Maven!) 50 | 51 | # Instructions 52 | These instructions show how to build and run 53 | [BusyTimeTest.java](client/freebusy/test/BusyTimeTest.java). To run 54 | a different freebusy client sample, follow these same instructions 55 | and substitute file names where appropriate. 56 | 57 | First create a root folder and sub-folder as shown below: 58 | 59 | ``` 60 | /tests 61 | /tests/swagger-java-client 62 | ``` 63 | 64 | The root folder name is not important. Choose a name other than 65 | **/tests** if necessary. 66 | 67 | ### Unzip the generated client code 68 | Unzip the generated code to **/tests/swagger-java-client**. When you 69 | are finished, the contents of the folder should look something like 70 | this: 71 | 72 | ``` 73 | docs 74 | gradle 75 | src 76 | .gitignore 77 | .swagger-codegen-ignore 78 | .travis.yml 79 | build.gradle 80 | build.sbt 81 | git_push.sh 82 | gradle.properties 83 | gradlew 84 | gradlew.bat 85 | pom.xml 86 | README.md 87 | settings.gradle 88 | ``` 89 | 90 | ### Use Maven to build the generated client code 91 | Build the generated client code and install it to your local Maven 92 | repository: 93 | 94 | ``` 95 | cd /tests/swagger-java-client 96 | mvn install 97 | ``` 98 | 99 | This step may take several seconds to complete. Move on to 100 | the next step only when you are sure you have a successful build: 101 | 102 | ``` 103 | [INFO] ------------------------------------------------------------------------ 104 | [INFO] BUILD SUCCESS 105 | [INFO] ------------------------------------------------------------------------ 106 | [INFO] Total time: 4.896 s 107 | [INFO] Finished at: 2017-02-22T14:26:49-05:00 108 | [INFO] Final Memory: 20M/34M 109 | [INFO] ------------------------------------------------------------------------ 110 | ``` 111 | 112 | ### Create your freebusy API test project 113 | Now run the following two commands: 114 | 115 | ``` 116 | cd /tests 117 | mvn archetype:generate -DgroupId=client.freebusy.test -DartifactId=client-freebusy-test -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false 118 | ``` 119 | 120 | That second command is definitely a mouthful, but when successful, 121 | it automatically creates a new Maven project based on a common 122 | template. The new project is in a folder called 123 | **/tests/client-freebusy-test**. You might want to take a 124 | moment to explore the contents of the new folder now. 125 | 126 | ### Customize your test project 127 | Look for a file named **pom.xml** in the 128 | **/tests/client-freebusy-test** folder. Open **pom.xml** 129 | in your favorite text editor and add the following lines 130 | inside the existing `` element: 131 | 132 | ``` 133 | 134 | io.swagger 135 | swagger-java-client 136 | 1.0.0 137 | compile 138 | 139 | ``` 140 | 141 | Save your changes to **pom.xml**. 142 | 143 | Now download [BusyTimeTest.java](client/freebusy/test/BusyTimeTest.java) 144 | to the **/tests/client-freebusy-test/src/main/java/client/freebusy/test** 145 | folder. Then open your local copy of **BusyTimeTest.java** in a text 146 | editor and customize the following values for your environment: 147 | 148 | ```java 149 | // IMPORTANT: Change these values to match your test environment: 150 | // 151 | // - basePath is the base URL for your Domino server. 152 | // The freebusy service MUST be installed and enabled 153 | // on the server. Be sure to change the protocol to 154 | // https if necessary. 155 | // 156 | // - user is the user name for HTTP authentication 157 | // 158 | // - password is the user's HTTP password 159 | // 160 | // - lookupName is the email address of a VALID user. 161 | // 162 | // - days is number of days of busy time data to return. 163 | // 164 | String basePath = "http://yourserver.yourorg.com"; 165 | String user = "First Last"; 166 | String password = "password"; 167 | String lookupName = "user@yourorg.com"; 168 | Integer days = 7; 169 | ``` 170 | 171 | ### Build your test project 172 | Run the following two commands: 173 | 174 | ``` 175 | cd /tests/client-freebusy-test 176 | mvn package 177 | ``` 178 | 179 | If your build is successful, you should see the following: 180 | 181 | ``` 182 | [INFO] 183 | [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ client-freebusy-test --- 184 | [INFO] Building jar: /tests/client-freebusy-test/target/client-freebusy-test-1.0-SNAPSHOT.jar 185 | [INFO] ------------------------------------------------------------------------ 186 | [INFO] BUILD SUCCESS 187 | [INFO] ------------------------------------------------------------------------ 188 | [INFO] Total time: 1.870 s 189 | [INFO] Finished at: 2017-02-22T15:04:06-05:00 190 | [INFO] Final Memory: 15M/25M 191 | [INFO] ------------------------------------------------------------------------ 192 | ``` 193 | 194 | ### Run your test project 195 | On Linux run the following command (note the use of *colons* to 196 | separate folders in the classpath): 197 | 198 | ``` 199 | java -cp "target/*:../swagger-java-client/target/*:../swagger-java-client/target/lib/*" client.freebusy.test.BusyTimeTest 200 | ``` 201 | 202 | On the other hand, if you are using Windows run the following 203 | (note the use of *semicolons* to separate folders in the 204 | classpath): 205 | 206 | ``` 207 | java -cp "target/*;../swagger-java-client/target/*;../swagger-java-client/target/lib/*" client.freebusy.test.BusyTimeTest 208 | ``` 209 | 210 | Either way, the above commands run the **BusyTimeTest** class with 211 | a classpath that includes the **client-freebusy-test** JAR (`target/*`), 212 | the generated client code (`../swagger-java-client/target/*`), and its 213 | dependencies (`../swagger-java-client/target/lib/*`). 214 | 215 | A successful run looks something like this: 216 | 217 | ``` 218 | Requesting busytime for dmelnyk@swg.usma.ibm.com ... 219 | Busytime request succeeded. Response follows ... 220 | 221 | start: 2017-02-23T17:00:00; end: 2017-02-23T18:00:00 222 | start: 2017-02-23T22:00:00; end: 2017-02-24T14:00:00 223 | start: 2017-02-24T17:00:00; end: 2017-02-24T18:00:00 224 | start: 2017-02-24T22:00:00; end: 2017-02-27T14:00:00 225 | start: 2017-02-27T17:00:00; end: 2017-02-27T18:00:00 226 | start: 2017-02-27T22:00:00; end: 2017-02-28T14:00:00 227 | start: 2017-02-28T17:00:00; end: 2017-02-28T20:00:00 228 | start: 2017-02-28T22:00:00; end: 2017-03-01T14:00:00 229 | start: 2017-03-01T17:00:00; end: 2017-03-01T18:00:00 230 | start: 2017-03-01T22:00:00; end: 2017-03-02T14:00:00 231 | ``` 232 | 233 | In other words, the **BusyTimeTest** class requests busy time 234 | for the specified user. If the request succeeds, it writes 235 | each busy time block to the console. The **BusyTimeTest** 236 | class does this with relatively simple calls into the 237 | generated client code. 238 | 239 | ### Next steps 240 | Here are some other things to try: 241 | 242 | - Review **BusyTimeTest.java** to better understand how it uses 243 | the generated client code. You might even want to step 244 | through the code in a debugger. 245 | 246 | - Add other test classes to the **client-freebusy-test** 247 | project. For example, see 248 | [FreeRoomsTest.java](client/freebusy/test/FreeRoomsTest.java) and 249 | [SitesTest.java](client/freebusy/test/SitesTest.java). 250 | As you add each new class, be sure to customize it for 251 | your test environment and rebuild the test project. Then 252 | run the new class and see what it does. 253 | 254 | - Explore the generated code in more detail. You might even 255 | want to write your own application to integrate with the Domino 256 | freebusy API. 257 | -------------------------------------------------------------------------------- /client-samples/calendar/java/README.md: -------------------------------------------------------------------------------- 1 | 15 | 16 | # Java samples using the DAS Calendar API 17 | Sample code showing use of Domino Access Services (DAS) with Swagger 18 | generated client code. You can use this code to test calendar API 19 | client code generated by 20 | [Swagger Codegen](https://github.com/swagger-api/swagger-codegen). 21 | 22 | ### Prerequisites 23 | - A Domino server with the calendar API installed and enabled. 24 | - A Java development kit (JDK). Java 7 is the minimum required 25 | version. 26 | - Apache Maven to build the Java code and automatically manage 27 | dependencies. 28 | - A Java client package generated from **calendar.yaml**. For example, 29 | you can use the [online Swagger editor](http://editor2.swagger.io) 30 | to import **calendar.yaml** and then generate a "Java" client. 31 | (*Note:* This repository does not include the generated code.) 32 | 33 | ### Required JARs 34 | The generated client package includes a Maven project object module 35 | (**pom.xml**) identifying several required JARs. Therefore, we 36 | recommend you use Maven to automatically build 37 | the project and manage its dependencies. If you choose not to 38 | use Maven, the list of required JARs is as currently follows: 39 | 40 | - gson-2.6.2.jar 41 | - joda-time-2.9.3.jar 42 | - logging-interceptor-2.7.5.jar 43 | - okhttp-2.7.5.jar 44 | - okio-1.6.0.jar 45 | - swagger-annotations-1.5.9.jar 46 | 47 | This list depends on the version of Swagger Codegen and is subject 48 | to change without notice. (In other words, you really should use 49 | Maven!) 50 | 51 | # Instructions 52 | These instructions show how to build and run 53 | [EventTest.java](client/calendar/test/EventTest.java). To run 54 | a different calendar client sample, follow these same instructions 55 | and substitute file names where appropriate. 56 | 57 | First create a root folder and sub-folder as shown below: 58 | 59 | ``` 60 | /tests 61 | /tests/swagger-java-client 62 | ``` 63 | 64 | The root folder name is not important. Choose a name other than 65 | **/tests** if necessary. 66 | 67 | ### Unzip the generated client code 68 | Unzip the generated code to **/tests/swagger-java-client**. When you 69 | are finished, the contents of the folder should look something like 70 | this: 71 | 72 | ``` 73 | docs 74 | gradle 75 | src 76 | .gitignore 77 | .swagger-codegen-ignore 78 | .travis.yml 79 | build.gradle 80 | build.sbt 81 | git_push.sh 82 | gradle.properties 83 | gradlew 84 | gradlew.bat 85 | pom.xml 86 | README.md 87 | settings.gradle 88 | ``` 89 | 90 | ### Use Maven to build the generated client code 91 | Build the generated client code and install it to your local Maven 92 | repository: 93 | 94 | ``` 95 | cd /tests/swagger-java-client 96 | mvn install 97 | ``` 98 | 99 | This step may take several seconds to complete. Move on to 100 | the next step only when you are sure you have a successful build: 101 | 102 | ``` 103 | [INFO] ------------------------------------------------------------------------ 104 | [INFO] BUILD SUCCESS 105 | [INFO] ------------------------------------------------------------------------ 106 | [INFO] Total time: 4.896 s 107 | [INFO] Finished at: 2017-02-22T14:26:49-05:00 108 | [INFO] Final Memory: 20M/34M 109 | [INFO] ------------------------------------------------------------------------ 110 | ``` 111 | 112 | ### Create your calendar API test project 113 | Now run the following two commands: 114 | 115 | ``` 116 | cd /tests 117 | mvn archetype:generate -DgroupId=client.calendar.test -DartifactId=client-calendar-test -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false 118 | ``` 119 | 120 | That second command is definitely a mouthful, but when successful, 121 | it automatically creates a new Maven project based on a common 122 | template. The new project is in a folder called 123 | **/tests/client-calendar-test**. You might want to take a 124 | moment to explore the contents of the new folder now. 125 | 126 | ### Customize your test project 127 | Look for a file named **pom.xml** in the 128 | **/tests/client-calendar-test** folder. Open **pom.xml** 129 | in your favorite text editor and add the following lines 130 | inside the existing `` element: 131 | 132 | ``` 133 | 134 | io.swagger 135 | swagger-java-client 136 | 1.0.0 137 | compile 138 | 139 | ``` 140 | 141 | Save your changes to **pom.xml**. 142 | 143 | Now download [EventTest.java](client/calendar/test/EventTest.java) 144 | to the **/tests/client-calendar-test/src/main/java/client/calendar/test** 145 | folder. Then open your local copy of **EventTest.java** in a text 146 | editor and customize the following values for your environment: 147 | 148 | ```java 149 | // IMPORTANT: Change these values to match your test environment: 150 | // 151 | // - basePath is the base URL for your Domino server. 152 | // The calendar service MUST be installed and enabled 153 | // on the server. Be sure to change the protocol to 154 | // https if necessary. 155 | // 156 | // - folder is the mail file database folder. 157 | // 158 | // - database is the mail file database name. 159 | // 160 | // - user is the user name of the owner of the mail file specified by 161 | // /{folder}/{database}. 162 | // 163 | // - password is the user's password. 164 | // 165 | String basePath = "http://yourserver.yourorg.com"; 166 | String folder = "mail"; 167 | String database = "database.nsf"; 168 | String user = "First Last"; 169 | String password = "password"; 170 | ``` 171 | 172 | ### Build your test project 173 | Run the following two commands: 174 | 175 | ``` 176 | cd /tests/client-calendar-test 177 | mvn package 178 | ``` 179 | 180 | If your build is successful, you should see the following: 181 | 182 | ``` 183 | [INFO] 184 | [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ client-calendar-test --- 185 | [INFO] Building jar: /tests/client-calendar-test/target/client-calendar-test-1.0-SNAPSHOT.jar 186 | [INFO] ------------------------------------------------------------------------ 187 | [INFO] BUILD SUCCESS 188 | [INFO] ------------------------------------------------------------------------ 189 | [INFO] Total time: 1.870 s 190 | [INFO] Finished at: 2017-02-22T15:04:06-05:00 191 | [INFO] Final Memory: 15M/25M 192 | [INFO] ------------------------------------------------------------------------ 193 | ``` 194 | 195 | ### Run your test project 196 | On Linux run the following command (note the use of *colons* to 197 | separate folders in the classpath): 198 | 199 | ``` 200 | java -cp "target/*:../swagger-java-client/target/*:../swagger-java-client/target/lib/*" client.calendar.test.EventTest 201 | ``` 202 | 203 | On the other hand, if you are using Windows run the following 204 | (note the use of *semicolons* to separate folders in the 205 | classpath): 206 | 207 | ``` 208 | java -cp "target/*;../swagger-java-client/target/*;../swagger-java-client/target/lib/*" client.calendar.test.EventTest 209 | ``` 210 | 211 | Either way, the above commands run the **EventTest** class with 212 | a classpath that includes the **client-calendar-test** JAR (`target/*`), 213 | the generated client code (`../swagger-java-client/target/*`), and its 214 | dependencies (`../swagger-java-client/target/lib/*`). 215 | 216 | A successful run looks something like this: 217 | 218 | ``` 219 | Creating an event in mail/dlawson.nsf ... 220 | Create event request succeeded. Location is http://yourserver.yourorg.com:80/mail/dlawson.nsf/api/calendar/events/F91363CD8C6465EA852580CF0070DC75-Lotus_Auto_Generated 221 | 222 | Reading event F91363CD8C6465EA852580CF0070DC75-Lotus_Auto_Generated from mail/dlawson.nsf ... 223 | Read event request succeeded. Response follows ... 224 | 225 | Event 0 226 | summary: API test 227 | location: test 228 | href: /mail/dlawson.nsf/api/calendar/events/F91363CD8C6465EA852580CF0070DC75-Lotus_Auto_Generated 229 | start: 2018-01-01T13:00:00 230 | end: 2018-01-01T14:00:00 231 | sequence: 0 232 | description: test 233 | 234 | Deleting event F91363CD8C6465EA852580CF0070DC75-Lotus_Auto_Generated from mail/dlawson.nsf ... 235 | ``` 236 | 237 | In other words, the **EventTest** class: 238 | 239 | - Creates an event on the test user's calendar. The subject 240 | of the event is "API test". 241 | - Reads the new event and writes the subject (a.k.a. summary), 242 | location, and other properties to the console. 243 | - Deletes the event. 244 | 245 | The **EventTest** class does all of the above with relatively simple 246 | calls into the generated client code. 247 | 248 | ### Next steps 249 | Here are some other things to try: 250 | 251 | - Review **EventTest.java** to better understand how it uses 252 | the generated client code. You might even want to step 253 | through the code in a debugger. 254 | 255 | - Add other test classes to the **client-calendar-test** 256 | project. For example, see 257 | [MeetingTest.java](client/calendar/test/MeetingTest.java) and 258 | [NoticeTest.java](client/calendar/test/NoticeTest.java). 259 | As you add each new class, be sure to customize it for 260 | your test environment and rebuild the test project. Then 261 | run the new class and see what it does. 262 | 263 | - Explore the generated code in more detail. You might even 264 | want to write your own application to integrate with the Domino 265 | calendar API. 266 | -------------------------------------------------------------------------------- /client-samples/calendar/java/client/calendar/test/EventTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | package client.calendar.test; 18 | 19 | import io.swagger.client.ApiClient; 20 | import io.swagger.client.ApiException; 21 | import io.swagger.client.ApiResponse; 22 | import io.swagger.client.api.EventApi; 23 | import io.swagger.client.model.Event; 24 | import io.swagger.client.model.EventRequest; 25 | import io.swagger.client.model.EventResponse; 26 | import io.swagger.client.model.ExDateTime; 27 | 28 | import java.util.List; 29 | import java.util.Map; 30 | import java.util.Set; 31 | 32 | public class EventTest { 33 | 34 | private EventApi _eventApi; 35 | 36 | public EventTest(String basePath, String username, String password) { 37 | _eventApi = new EventApi(); 38 | ApiClient client = _eventApi.getApiClient(); 39 | client.setBasePath(basePath); 40 | client.setUsername(username); 41 | client.setPassword(password); 42 | } 43 | 44 | public static void main(String[] args) { 45 | 46 | // IMPORTANT: Change these values to match your test environment: 47 | // 48 | // - basePath is the base URL for your Domino server. 49 | // The calendar service MUST be installed and enabled 50 | // on the server. Be sure to change the protocol to 51 | // https if necessary. 52 | // 53 | // - folder is the mail file database folder. 54 | // 55 | // - database is the mail file database name. 56 | // 57 | // - user is the user name of the owner of the mail file specified by 58 | // /{folder}/{database}. 59 | // 60 | // - password is the user's password. 61 | // 62 | String basePath = "http://yourserver.yourorg.com"; 63 | String folder = "mail"; 64 | String database = "database.nsf"; 65 | String user = "First Last"; 66 | String password = "password"; 67 | 68 | // Create an instance of the test class 69 | EventTest test = new EventTest(basePath, user, password); 70 | 71 | // Create an event 72 | String uid = test.createEvent(folder, database); 73 | 74 | if (uid != null) { 75 | // Read the event 76 | test.readEvent(folder, database, uid); 77 | 78 | // Delete the event 79 | test.deleteEvent(folder, database, uid); 80 | } 81 | 82 | } 83 | 84 | /** 85 | * Creates an appointment on the user's calendar. 86 | * 87 | * @param folder 88 | * @param database 89 | * @return 90 | */ 91 | private String createEvent(String folder, String database) { 92 | String uid = null; 93 | Event event = new Event(); 94 | event.setSummary("API test"); 95 | event.setLocation("test"); 96 | event.setDescription("test"); 97 | 98 | ExDateTime start = new ExDateTime(); 99 | start.setDate("2018-01-01"); 100 | start.setTime("13:00:00"); 101 | start.setUtc(true); 102 | event.setStart(start); 103 | 104 | ExDateTime end = new ExDateTime(); 105 | end.setDate("2018-01-01"); 106 | end.setTime("14:00:00"); 107 | end.setUtc(true); 108 | event.setEnd(end); 109 | 110 | EventRequest request = new EventRequest(); 111 | request.getEvents().add(event); 112 | 113 | try { 114 | 115 | // Create an event 116 | System.out.println("Creating an event in " + folder + "/" + database + " ..."); 117 | ApiResponse result = _eventApi.folderDatabaseApiCalendarEventsPostWithHttpInfo(folder, 118 | database, request, true); 119 | 120 | // Extract the Location header 121 | String location = null; 122 | Map> headers = result.getHeaders(); 123 | if (headers != null) { 124 | Set keys = headers.keySet(); 125 | for (String key : keys) { 126 | if (key.equalsIgnoreCase("Location")) { 127 | location = headers.get(key).get(0); 128 | break; 129 | } 130 | } 131 | } 132 | 133 | // Extract the UID from the location 134 | if (location != null) { 135 | // Dump the Location header 136 | System.out.println("Create event request succeeded. Location is " + location); 137 | 138 | int index = location.lastIndexOf('/'); 139 | if (index != -1) { 140 | uid = location.substring(index + 1, location.length()); 141 | } 142 | } 143 | else { 144 | // Unexpected response 145 | System.out.println("Create event request succeeded, but the response doesn't include a Location header."); 146 | } 147 | 148 | System.out.println(); 149 | } 150 | catch (ApiException e) { 151 | System.err.println("Exception when calling EventApi#folderDatabaseApiCalendarEventsPostWithHttpInfo"); 152 | String body = e.getResponseBody(); 153 | if (body != null) { 154 | System.err.println("Response from server ..."); 155 | System.err.println(body); 156 | } 157 | else { 158 | e.printStackTrace(); 159 | } 160 | } 161 | 162 | return uid; 163 | } 164 | 165 | /** 166 | * Reads an event and dumps its properties to the console. 167 | * 168 | * @param folder 169 | * @param database 170 | * @param uid 171 | */ 172 | private void readEvent(String folder, String database, String uid) { 173 | try { 174 | 175 | // Read the event 176 | System.out.println("Reading event " + uid + " from " + folder + "/" + database + " ..."); 177 | EventResponse result = _eventApi.folderDatabaseApiCalendarEventsUidGet(folder, database, uid, null); 178 | 179 | // Does the response have events? 180 | List events = result.getEvents(); 181 | if (events != null) { 182 | 183 | // Dump the events 184 | System.out.println("Read event request succeeded. Response follows ...\n"); 185 | for (int i = 0; i < events.size(); i++) { 186 | Event event = events.get(i); 187 | System.out.println("Event " + i); 188 | System.out.println(" summary: " + event.getSummary()); 189 | System.out.println(" location: " + event.getLocation()); 190 | System.out.println(" href: " + event.getHref()); 191 | 192 | String start = event.getStart().getDate(); 193 | if (event.getStart().getTime() != null) { 194 | start += "T" + event.getStart().getTime(); 195 | } 196 | System.out.println(" start: " + start); 197 | 198 | String end = event.getEnd().getDate(); 199 | if (event.getEnd().getTime() != null) { 200 | end += "T" + event.getEnd().getTime(); 201 | } 202 | System.out.println(" end: " + end); 203 | 204 | System.out.println(" sequence: " + event.getSequence()); 205 | System.out.println(" description: " + event.getDescription()); 206 | } 207 | } 208 | else { 209 | 210 | // Unexpected response 211 | System.out.println("Read event request succeeded, but the response doesn't include a list of events."); 212 | } 213 | } 214 | catch (ApiException e) { 215 | System.err.println("Exception when calling EventApi#folderDatabaseApiCalendarEventsUidGet"); 216 | String body = e.getResponseBody(); 217 | if (body != null) { 218 | System.err.println("Response from server ..."); 219 | System.err.println(body); 220 | } 221 | else { 222 | e.printStackTrace(); 223 | } 224 | } 225 | } 226 | 227 | /** 228 | * Deletes an event from the user's calendar. 229 | * 230 | * @param folder 231 | * @param database 232 | * @param uid 233 | */ 234 | private void deleteEvent(String folder, String database, String uid) { 235 | try { 236 | 237 | // Delete the event 238 | System.out.println("Deleting event " + uid + " from " + folder + "/" + database + " ..."); 239 | _eventApi.folderDatabaseApiCalendarEventsUidDelete(folder, database, uid, true); 240 | 241 | } 242 | catch (ApiException e) { 243 | System.err.println("Exception when calling EventApi#folderDatabaseApiCalendarEventsUidDelete"); 244 | String body = e.getResponseBody(); 245 | if (body != null) { 246 | System.err.println("Response from server ..."); 247 | System.err.println(body); 248 | } 249 | else { 250 | e.printStackTrace(); 251 | } 252 | } 253 | } 254 | } 255 | -------------------------------------------------------------------------------- /client-samples/mail/java/README.md: -------------------------------------------------------------------------------- 1 | 15 | 16 | # Java samples using the DAS Mail API 17 | Sample code showing use of Domino Access Services (DAS) with Swagger 18 | generated client code. You can use this code to test mail API 19 | client code generated by 20 | [Swagger Codegen](https://github.com/swagger-api/swagger-codegen). 21 | 22 | ### Prerequisites 23 | - A Domino server with the mail API installed and enabled. 24 | - A Java development kit (JDK). Java 7 is the minimum required 25 | version. 26 | - Apache Maven to build the Java code and automatically manage 27 | dependencies. 28 | - A Java client package generated from **mail.yaml**. For example, 29 | you can use the [online Swagger editor](http://editor2.swagger.io) 30 | to import **mail.yaml** and then generate a "Java" client. 31 | (*Note:* This repository does not include the generated code.) 32 | 33 | ### Required JARs 34 | The generated client package includes a Maven project object module 35 | (**pom.xml**) identifying several required JARs. Therefore, we 36 | recommend you use Maven to automatically build 37 | the project and manage its dependencies. If you choose not to 38 | use Maven, the list of required JARs is as currently follows: 39 | 40 | - gson-2.6.2.jar 41 | - joda-time-2.9.3.jar 42 | - logging-interceptor-2.7.5.jar 43 | - okhttp-2.7.5.jar 44 | - okio-1.6.0.jar 45 | - swagger-annotations-1.5.9.jar 46 | 47 | This list depends on the version of Swagger Codegen and is subject 48 | to change without notice. (In other words, you really should use 49 | Maven!) 50 | 51 | # Instructions 52 | These instructions show how to build and run 53 | [MessageTest.java](client/mail/test/MessageTest.java). To run 54 | a different mail client sample, follow these same instructions 55 | and substitute file names where appropriate. 56 | 57 | First create a root folder and sub-folder as shown below: 58 | 59 | ``` 60 | /tests 61 | /tests/swagger-java-client 62 | ``` 63 | 64 | The root folder name is not important. Choose a name other than 65 | **/tests** if necessary. 66 | 67 | ### Unzip the generated client code 68 | Unzip the generated code to **/tests/swagger-java-client**. When you 69 | are finished, the contents of the folder should look something like 70 | this: 71 | 72 | ``` 73 | docs 74 | gradle 75 | src 76 | .gitignore 77 | .swagger-codegen-ignore 78 | .travis.yml 79 | build.gradle 80 | build.sbt 81 | git_push.sh 82 | gradle.properties 83 | gradlew 84 | gradlew.bat 85 | pom.xml 86 | README.md 87 | settings.gradle 88 | ``` 89 | 90 | ### Use Maven to build the generated client code 91 | Build the generated client code and install it to your local Maven 92 | repository: 93 | 94 | ``` 95 | cd /tests/swagger-java-client 96 | mvn install 97 | ``` 98 | 99 | This step may take several seconds to complete. Move on to 100 | the next step only when you are sure you have a successful build: 101 | 102 | ``` 103 | [INFO] ------------------------------------------------------------------------ 104 | [INFO] BUILD SUCCESS 105 | [INFO] ------------------------------------------------------------------------ 106 | [INFO] Total time: 4.896 s 107 | [INFO] Finished at: 2017-02-22T14:26:49-05:00 108 | [INFO] Final Memory: 20M/34M 109 | [INFO] ------------------------------------------------------------------------ 110 | ``` 111 | 112 | ### Create your mail API test project 113 | Now run the following two commands: 114 | 115 | ``` 116 | cd /tests 117 | mvn archetype:generate -DgroupId=client.mail.test -DartifactId=client-mail-test -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false 118 | ``` 119 | 120 | That second command is complicated, but when successful, 121 | it automatically creates a new Maven project based on a common 122 | template. The new project is in a folder called 123 | **/tests/client-mail-test**. You might want to take a 124 | moment to explore the contents of the new folder now. 125 | 126 | ### Customize your test project 127 | Look for a file named **pom.xml** in the 128 | **/tests/client-mail-test** folder. Open **pom.xml** 129 | in your favorite text editor and add the following lines 130 | inside the existing `` element: 131 | 132 | ``` 133 | 134 | io.swagger 135 | swagger-java-client 136 | 1.0.0 137 | compile 138 | 139 | ``` 140 | 141 | Save your changes to **pom.xml**. 142 | 143 | Now download [MessageTest.java](client/mail/test/MessageTest.java) 144 | to the **/tests/client-mail-test/src/main/java/client/mail/test** 145 | folder. Then open your local copy of **MessageTest.java** in a text 146 | editor and customize the following values for your environment: 147 | 148 | ```java 149 | // IMPORTANT: Change these values to match your test environment: 150 | // 151 | // - basePath is the base URL for your Domino server. 152 | // The mail service MUST be installed and enabled 153 | // on the server. Be sure to change the protocol to 154 | // https if necessary. 155 | // 156 | // - folder is the mail file database folder. The folder is relative 157 | // to the Domino data directory. Use "." if the mail file 158 | // is in the data directory itself. 159 | // 160 | // - database is the mail file database name. 161 | // 162 | // - user is the user name of the owner of the mail file specified by 163 | // /{folder}/{database}. 164 | // 165 | // - password is the user's password. 166 | // 167 | // - sendTo is the email address of a recipient 168 | // 169 | String basePath = "http://yourserver.yourorg.com"; 170 | String folder = "mail"; 171 | String database = "database.nsf"; 172 | String user = "First Last"; 173 | String password = "password"; 174 | String sendTo = "recipient@yourorg.com"; 175 | ``` 176 | 177 | ### Build your test project 178 | Run the following two commands: 179 | 180 | ``` 181 | cd /tests/client-mail-test 182 | mvn package 183 | ``` 184 | 185 | If your build is successful, you should see the following: 186 | 187 | ``` 188 | [INFO] 189 | [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ client-mail-test --- 190 | [INFO] Building jar: /tests/client-mail-test/target/client-mail-test-1.0-SNAPSHOT.jar 191 | [INFO] ------------------------------------------------------------------------ 192 | [INFO] BUILD SUCCESS 193 | [INFO] ------------------------------------------------------------------------ 194 | [INFO] Total time: 1.870 s 195 | [INFO] Finished at: 2017-02-22T15:04:06-05:00 196 | [INFO] Final Memory: 15M/25M 197 | [INFO] ------------------------------------------------------------------------ 198 | ``` 199 | 200 | ### Run your test project 201 | On Linux run the following command (note the use of *colons* to 202 | separate folders in the classpath): 203 | 204 | ``` 205 | java -cp "target/*:../swagger-java-client/target/*:../swagger-java-client/target/lib/*" client.mail.test.MessageTest 206 | ``` 207 | 208 | On the other hand, if you are using Windows run the following 209 | (note the use of *semicolons* to separate folders in the 210 | classpath): 211 | 212 | ``` 213 | java -cp "target/*;../swagger-java-client/target/*;../swagger-java-client/target/lib/*" client.mail.test.MessageTest 214 | ``` 215 | 216 | Either way, the above commands run the **MessageTest** class with 217 | a classpath that includes the **client-mail-test** JAR (`target/*`), 218 | the generated client code (`../swagger-java-client/target/*`), and its 219 | dependencies (`../swagger-java-client/target/lib/*`). 220 | 221 | A successful run looks something like this: 222 | 223 | ``` 224 | Sending message from mail/database.nsf ... 225 | Send message request succeeded. Location is http://yourserver.yourorg.com:80/mail/database.nsf/api/mail/messages/2A3C4E50234ADA95852580E600534390 226 | 227 | Reading message 2A3C4E50234ADA95852580E600534390 from mail/database.nsf ... 228 | Read message request succeeded. Response follows ... 229 | subject: Test message from Swagger generated Java client code 230 | date: 2017-03-17T15:09:27Z 231 | 232 | contentType: text/plain 233 | data: This is a test. 234 | 235 | contentType: text/html 236 | data: This is a test.

This is only a test! 237 | ``` 238 | 239 | In other words, the **MessageTest** class sends a test message to 240 | the specified recipient. Then it reads the sent message and dumps its 241 | contents to the console. The **MessageTest** class does this with relatively 242 | simple calls into the generated client code. 243 | 244 | ### Next steps 245 | Here are some other things to try: 246 | 247 | - Review **MessageTest.java** to better understand how it uses 248 | the generated client code. You might even want to step 249 | through the code in a debugger. 250 | 251 | - **MessageTest** sends a message in **multipart/alternative** 252 | format, but the mail API allows you to represent virtually any 253 | MIME structure in JSON format. Try changing the contents of the 254 | test message. 255 | 256 | - Add other test classes to the **client-mail-test** 257 | project. For example, see 258 | [DraftMessageTest.java](client/mail/test/DraftMessageTest.java) and 259 | [MessageListTest.java](client/mail/test/MessageListTest.java). 260 | As you add each new class, be sure to customize it for 261 | your test environment and rebuild the test project. Then 262 | run the new class and see what it does. 263 | 264 | - Explore the generated code in more detail. You might even 265 | want to write your own application to integrate with the Domino 266 | mail API. 267 | -------------------------------------------------------------------------------- /client-samples/data/java/README.md: -------------------------------------------------------------------------------- 1 | 15 | 16 | # Java samples using the DAS Data API 17 | Sample code showing use of Domino Access Services (DAS) with Swagger 18 | generated client code. You can use this code to test data API 19 | client code generated by 20 | [Swagger Codegen](https://github.com/swagger-api/swagger-codegen). 21 | 22 | ### Prerequisites 23 | - A Domino server with the data API installed and enabled. 24 | - At least one server database with the data API enabled. 25 | For example, you may want to use the demo database from 26 | the XPages Extension Library (XLibExt.nsf). 27 | - A Java development kit (JDK). Java 7 is the minimum required 28 | version. 29 | - Apache Maven to build the Java code and automatically manage 30 | dependencies. 31 | - A Java client package generated from **data.yaml**. For example, 32 | you can use the [online Swagger editor](http://editor2.swagger.io) 33 | to import **data.yaml** and then generate a "Java" client. 34 | (*Note:* This repository does not include the generated code.) 35 | 36 | ### Required JARs 37 | The generated client package includes a Maven project object module 38 | (**pom.xml**) identifying several required JARs. Therefore, we 39 | recommend you use Maven to automatically build 40 | the project and manage its dependencies. If you choose not to 41 | use Maven, the list of required JARs is as currently follows: 42 | 43 | - gson-2.6.2.jar 44 | - joda-time-2.9.3.jar 45 | - logging-interceptor-2.7.5.jar 46 | - okhttp-2.7.5.jar 47 | - okio-1.6.0.jar 48 | - swagger-annotations-1.5.9.jar 49 | 50 | This list depends on the version of Swagger Codegen and is subject 51 | to change without notice. (In other words, you really should use 52 | Maven!) 53 | 54 | # Instructions 55 | These instructions show how to build and run 56 | [DocumentTest.java](client/data/test/DocumentTest.java). To run 57 | a different data API client sample, follow these same instructions 58 | and substitute file names where appropriate. 59 | 60 | First create a root folder and sub-folder as shown below: 61 | 62 | ``` 63 | /tests 64 | /tests/swagger-java-client 65 | ``` 66 | 67 | The root folder name is not important. Choose a name other than 68 | **/tests** if necessary. 69 | 70 | ### Unzip the generated client code 71 | Unzip the generated code to **/tests/swagger-java-client**. When you 72 | are finished, the contents of the folder should look something like 73 | this: 74 | 75 | ``` 76 | docs 77 | gradle 78 | src 79 | .gitignore 80 | .swagger-codegen-ignore 81 | .travis.yml 82 | build.gradle 83 | build.sbt 84 | git_push.sh 85 | gradle.properties 86 | gradlew 87 | gradlew.bat 88 | pom.xml 89 | README.md 90 | settings.gradle 91 | ``` 92 | 93 | ### Use Maven to build the generated client code 94 | Build the generated client code and install it to your local Maven 95 | repository: 96 | 97 | ``` 98 | cd /tests/swagger-java-client 99 | mvn install 100 | ``` 101 | 102 | This step may take several seconds to complete. Move on to 103 | the next step only when you are sure you have a successful build: 104 | 105 | ``` 106 | [INFO] ------------------------------------------------------------------------ 107 | [INFO] BUILD SUCCESS 108 | [INFO] ------------------------------------------------------------------------ 109 | [INFO] Total time: 4.896 s 110 | [INFO] Finished at: 2017-02-22T14:26:49-05:00 111 | [INFO] Final Memory: 20M/34M 112 | [INFO] ------------------------------------------------------------------------ 113 | ``` 114 | 115 | ### Create your data API test project 116 | Now run the following two commands: 117 | 118 | ``` 119 | cd /tests 120 | mvn archetype:generate -DgroupId=client.data.test -DartifactId=client-data-test -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false 121 | ``` 122 | 123 | That second command is complicated, but when successful, 124 | it automatically creates a new Maven project based on a common 125 | template. The new project is in a folder called 126 | **/tests/client-data-test**. You might want to take a 127 | moment to explore the contents of the new folder now. 128 | 129 | ### Customize your test project 130 | Look for a file named **pom.xml** in the 131 | **/tests/client-data-test** folder. Open **pom.xml** 132 | in your favorite text editor and add the following lines 133 | inside the existing `` element: 134 | 135 | ``` 136 | 137 | io.swagger 138 | swagger-java-client 139 | 1.0.0 140 | compile 141 | 142 | ``` 143 | 144 | Save your changes to **pom.xml**. 145 | 146 | Now download [DocumentTest.java](client/data/test/DocumentTest.java) 147 | to the **/tests/client-data-test/src/main/java/client/data/test** 148 | folder. Then open your local copy of **DocumentTest.java** in a text 149 | editor and customize the following values for your environment: 150 | 151 | ```java 152 | // IMPORTANT: Change these values to match your test environment: 153 | // 154 | // - basePath is the base URL for your Domino server. 155 | // The data service MUST be installed and enabled 156 | // on the server. Be sure to change the protocol to 157 | // https if necessary. 158 | // 159 | // - username is the user name of someone with access 160 | // the server. 161 | // 162 | // - password is the user's password. 163 | // 164 | // - folder is database folder name relative to the Domino 165 | // data directory. Use "." if the database is in the 166 | // data directory itself. 167 | // 168 | // - database is the name of the database. The database 169 | // must allow access from the data service. Use 170 | // "XPagesExt.nsf" if your server has a copy of the 171 | // XPages Extension Library demo database. 172 | // 173 | // - formName is the name of a form in the database. 174 | // 175 | String basePath = "http://yourserver.yourorg.com"; 176 | String username = "First Last"; 177 | String password = "password"; 178 | String folder = "."; 179 | String database = "XPagesExt.nsf"; 180 | String formName = "AllTypes"; 181 | ``` 182 | 183 | ### Build your test project 184 | Run the following two commands: 185 | 186 | ``` 187 | cd /tests/client-data-test 188 | mvn package 189 | ``` 190 | 191 | If your build is successful, you should see the following: 192 | 193 | ``` 194 | [INFO] 195 | [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ client-data-test --- 196 | [INFO] Building jar: /tests/client-data-test/target/client-data-test-1.0-SNAPSHOT.jar 197 | [INFO] ------------------------------------------------------------------------ 198 | [INFO] BUILD SUCCESS 199 | [INFO] ------------------------------------------------------------------------ 200 | [INFO] Total time: 1.870 s 201 | [INFO] Finished at: 2017-02-22T15:04:06-05:00 202 | [INFO] Final Memory: 15M/25M 203 | [INFO] ------------------------------------------------------------------------ 204 | ``` 205 | 206 | ### Run your test project 207 | On Linux run the following command (note the use of *colons* to 208 | separate folders in the classpath): 209 | 210 | ``` 211 | java -cp "target/*:../swagger-java-client/target/*:../swagger-java-client/target/lib/*" client.data.test.DocumentTest 212 | ``` 213 | 214 | On the other hand, if you are using Windows run the following 215 | (note the use of *semicolons* to separate folders in the 216 | classpath): 217 | 218 | ``` 219 | java -cp "target/*;../swagger-java-client/target/*;../swagger-java-client/target/lib/*" client.data.test.DocumentTest 220 | ``` 221 | 222 | Either way, the above commands run the **DocumentTest** class with 223 | a classpath that includes the **client-data-test** JAR (`target/*`), 224 | the generated client code (`../swagger-java-client/target/*`), and its 225 | dependencies (`../swagger-java-client/target/lib/*`). 226 | 227 | A successful run looks something like this: 228 | 229 | ``` 230 | Creating a new document ... 231 | Create document request succeeded. Location is http://yourserver.yourorg.com:80/XPagesExt.nsf/api/data/documents/unid/65720145FF81B387852580E2005E69EF 232 | 233 | Reading document 65720145FF81B387852580E2005E69EF... 234 | Read document request succeeded 235 | 236 | Updating document 65720145FF81B387852580E2005E69EF... 237 | Update document request succeeded 238 | 239 | Reading document 65720145FF81B387852580E2005E69EF... 240 | Read document request succeeded 241 | 242 | Deleting document 65720145FF81B387852580E2005E69EF... 243 | ``` 244 | 245 | In other words, the **DocumentTest** class: 246 | 247 | - Creates a new document. 248 | - Reads the new document and validates it contains the 249 | expected items. 250 | - Updates the document. 251 | - Reads and validates the updated document. 252 | - Deletes the document. 253 | 254 | The **DocumentTest** class does all of the above with relatively 255 | simple calls into the generated client code. 256 | 257 | ### Next steps 258 | Here are some other things to try: 259 | 260 | - Review **DocumentTest.java** to better understand how it uses 261 | the generated client code. You might even want to step 262 | through the code in a debugger. 263 | 264 | - Add other test classes to the **client-data-test** 265 | project. For example, see 266 | [DatabaseListTest.java](client/data/test/DatabaseListTest.java), 267 | [DocumentListTest.java](client/data/test/DocumentListTest.java), 268 | [ViewDesignTest.java](client/data/test/ViewDesignTest.java), and 269 | [ViewEntryListTest.java](client/data/test/ViewEntryListTest.java). 270 | As you add each new class, be sure to customize it for 271 | your test environment and rebuild the test project. Then 272 | run the new class and see what it does. 273 | 274 | - Explore the generated code in more detail. You might even 275 | want to write your own application to integrate with the Domino 276 | data API. 277 | -------------------------------------------------------------------------------- /client-samples/calendar/java/client/calendar/test/NoticeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | package client.calendar.test; 18 | 19 | import io.swagger.client.ApiClient; 20 | import io.swagger.client.ApiException; 21 | import io.swagger.client.ApiResponse; 22 | import io.swagger.client.api.NoticeApi; 23 | import io.swagger.client.api.NoticeListApi; 24 | import io.swagger.client.model.ActionRequest; 25 | import io.swagger.client.model.Event; 26 | import io.swagger.client.model.NoticeResponse; 27 | import io.swagger.client.model.NoticeSummariesResponse; 28 | import io.swagger.client.model.NoticeSummary; 29 | 30 | import java.util.List; 31 | 32 | public class NoticeTest { 33 | 34 | private NoticeListApi _noticeListApi = null; 35 | private NoticeApi _noticeApi = null; 36 | 37 | public NoticeTest(String basePath, String username, String password) { 38 | _noticeListApi = new NoticeListApi(); 39 | ApiClient client = _noticeListApi.getApiClient(); 40 | client.setBasePath(basePath); 41 | client.setUsername(username); 42 | client.setPassword(password); 43 | 44 | _noticeApi = new NoticeApi(); 45 | } 46 | 47 | public static void main(String[] args) { 48 | 49 | // IMPORTANT: Change these values to match your test environment: 50 | // 51 | // - basePath is the base URL for your Domino server. 52 | // The calendar service MUST be installed and enabled 53 | // on the server. Be sure to change the protocol to 54 | // https if necessary. 55 | // 56 | // - folder is the mail file database folder. 57 | // 58 | // - database is the mail file database name. 59 | // 60 | // - user is the mail file owner's user name (for HTTP authentication). 61 | // 62 | // - password is the owner's HTTP password. 63 | // 64 | String basePath = "http://yourserver.yourorg.com"; 65 | String folder = "mail"; 66 | String database = "database.nsf"; 67 | String user = "First Last"; 68 | String password = "password"; 69 | 70 | // Parse command line 71 | boolean acceptInvites = false; 72 | for (int i = 0; i < args.length; i++) { 73 | if ("-a".equalsIgnoreCase(args[i])) { 74 | acceptInvites = true; 75 | } 76 | } 77 | 78 | // Get an instance of the test class 79 | NoticeTest test = new NoticeTest(basePath, user, password); 80 | 81 | // Read the list of invitations 82 | List summaries = test.readInvitations(folder, database); 83 | 84 | // Read individual notices 85 | if (summaries != null) { 86 | for (NoticeSummary summary : summaries) { 87 | String id = null; 88 | String href = summary.getHref(); 89 | int index = href.lastIndexOf('/'); 90 | if (index != -1) { 91 | id = href.substring(index + 1); 92 | } 93 | 94 | if (id != null) { 95 | 96 | // Read it 97 | test.readNotice(folder, database, id); 98 | 99 | // Accept the invite 100 | if (acceptInvites) { 101 | test.acceptInvite(folder, database, id); 102 | } 103 | } 104 | } 105 | } 106 | 107 | } 108 | 109 | /** 110 | * Reads a list of unapplied invitations. 111 | * 112 | * @param folder 113 | * @param database 114 | * @return 115 | */ 116 | private List readInvitations(String folder, String database) { 117 | List summaries = null; 118 | 119 | try { 120 | // Request a list of events 121 | System.out.println("Requesting invitations from " + folder + "/" + database + " ..."); 122 | NoticeSummariesResponse result = _noticeListApi.folderDatabaseApiCalendarInvitationsGet(folder, database, null, null); 123 | 124 | // Extract notice summaries from the response 125 | if (result != null) { 126 | summaries = result.getNotices(); 127 | } 128 | 129 | // Does the response have summaries? 130 | if (summaries != null) { 131 | 132 | // Dump the events 133 | System.out.println("Get invitations request succeeded. Response follows ...\n"); 134 | for (int i = 0; i < summaries.size(); i++) { 135 | NoticeSummary notice = summaries.get(i); 136 | System.out.println("Notice " + i); 137 | System.out.println(" summary: " + notice.getSummary()); 138 | System.out.println(" schedule method: " + notice.getScheduleMethod()); 139 | System.out.println(" href: " + notice.getHref()); 140 | 141 | System.out.println(); 142 | } 143 | } 144 | else { 145 | 146 | // Unexpected response 147 | System.err.println("Get invitations request succeeded, but the response doesn't include a list of notices."); 148 | } 149 | } 150 | catch (ApiException e) { 151 | System.err.println("Exception when calling NoticeListApi#folderDatabaseApiCalendarInvitationsGet"); 152 | String body = e.getResponseBody(); 153 | if (body != null) { 154 | System.err.println("Response from server ..."); 155 | System.err.println(body); 156 | } 157 | else { 158 | e.printStackTrace(); 159 | } 160 | } 161 | 162 | return summaries; 163 | } 164 | 165 | /** 166 | * Reads a single notice. 167 | * 168 | * @param folder 169 | * @param database 170 | * @param id 171 | */ 172 | private void readNotice(String folder, String database, String id) { 173 | try { 174 | // Request a notice 175 | System.out.println("Requesting notice " + id + " from " + folder + "/" + database + " ..."); 176 | NoticeResponse result = _noticeApi.folderDatabaseApiCalendarNoticesIdGet(folder, database, id, null); 177 | 178 | // Does the response have events? 179 | List events = result.getEvents(); 180 | if (events != null) { 181 | 182 | // Dump the events 183 | System.out.println("Get notice request succeeded. Response follows ...\n"); 184 | for (int i = 0; i < events.size(); i++) { 185 | Event event = events.get(i); 186 | System.out.println("Event " + i); 187 | System.out.println(" summary: " + event.getSummary()); 188 | System.out.println(" organizer: " + event.getOrganizer().getDisplayName()); 189 | 190 | if (event.getXLotusNoticetype() != null) { 191 | System.out.println(" x-lotus-noticetype: " + event.getXLotusNoticetype().getData()); 192 | } 193 | 194 | String start = event.getStart().getDate(); 195 | if (event.getStart().getTime() != null) { 196 | start += "T" + event.getStart().getTime(); 197 | } 198 | System.out.println(" start: " + start); 199 | 200 | String end = event.getEnd().getDate(); 201 | if (event.getEnd().getTime() != null) { 202 | end += "T" + event.getEnd().getTime(); 203 | } 204 | System.out.println(" end: " + end); 205 | 206 | System.out.println(); 207 | } 208 | } 209 | else { 210 | // Unexpected response 211 | System.err.println("Get notice request succeeded, but the response doesn't include a list of events."); 212 | } 213 | } 214 | catch (ApiException e) { 215 | System.err.println("Exception when calling NoticeApi#folderDatabaseApiCalendarNoticesIdGet"); 216 | String body = e.getResponseBody(); 217 | if (body != null) { 218 | System.err.println("Response from server ..."); 219 | System.err.println(body); 220 | } 221 | else { 222 | e.printStackTrace(); 223 | } 224 | } 225 | } 226 | 227 | /** 228 | * Accept in invitation notice. 229 | * 230 | * @param folder 231 | * @param database 232 | * @param id 233 | */ 234 | private void acceptInvite(String folder, String database, String id) { 235 | try { 236 | ActionRequest body = new ActionRequest(); 237 | body.setComments("I'll be there."); 238 | 239 | // Accept the invitation 240 | System.out.println("Accepting notice " + id + " from " + folder + "/" + database + " ..."); 241 | ApiResponse result = _noticeApi.folderDatabaseApiCalendarNoticesIdActionPutWithHttpInfo(folder, 242 | database, id, "accept", body); 243 | 244 | // Check the result 245 | if (result != null && result.getStatusCode() == 200) { 246 | System.out.println("Invitation was accepted"); 247 | } 248 | else { 249 | System.out.println("Unexpected reponse from API"); 250 | } 251 | 252 | } 253 | catch (ApiException e) { 254 | System.err.println("Exception when calling NoticeApi#folderDatabaseApiCalendarNoticesIdActionPutWithHttpInfo"); 255 | String body = e.getResponseBody(); 256 | if (body != null) { 257 | System.err.println("Response from server ..."); 258 | System.err.println(body); 259 | } 260 | else { 261 | e.printStackTrace(); 262 | } 263 | } 264 | } 265 | } 266 | -------------------------------------------------------------------------------- /client-samples/calendar/java/client/calendar/test/MeetingTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * © Copyright IBM Corp. 2017 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | package client.calendar.test; 18 | 19 | import io.swagger.client.ApiClient; 20 | import io.swagger.client.ApiException; 21 | import io.swagger.client.ApiResponse; 22 | import io.swagger.client.api.EventApi; 23 | import io.swagger.client.model.Attendee; 24 | import io.swagger.client.model.Event; 25 | import io.swagger.client.model.EventRequest; 26 | import io.swagger.client.model.EventResponse; 27 | import io.swagger.client.model.ExDateTime; 28 | import io.swagger.client.model.Organizer; 29 | 30 | import java.util.List; 31 | import java.util.Map; 32 | import java.util.Set; 33 | 34 | public class MeetingTest { 35 | 36 | private EventApi _eventApi; 37 | 38 | public MeetingTest(String basePath, String user, String password) { 39 | _eventApi = new EventApi(); 40 | ApiClient client = _eventApi.getApiClient(); 41 | client.setBasePath(basePath); 42 | client.setUsername(user); 43 | client.setPassword(password); 44 | } 45 | 46 | public static void main(String[] args) { 47 | 48 | // IMPORTANT: Change these values to match your test environment: 49 | // 50 | // - basePath is the base URL for your Domino server. 51 | // The calendar service MUST be installed and enabled 52 | // on the server. Be sure to change the protocol to 53 | // https if necessary. 54 | // 55 | // - folder is mail file database folder. 56 | // 57 | // - database is the mail file database name. 58 | // 59 | // - user is the user name of the owner of the mail file specified by 60 | // /{folder}/{database}. 61 | // 62 | // - password is the user's password. 63 | // 64 | // - organizerEmail is the email address of the event organizer. This is 65 | // usually the internet address of {user} 66 | // 67 | // - attendeeEmail is the email address of an invitee. 68 | // 69 | String basePath = "http://yourserver.yourorg.com"; 70 | String folder = "mail"; 71 | String database = "database.nsf"; 72 | String user = "First Last"; 73 | String password = "password"; 74 | String organizerEmail = "organizer@yourorg.com"; 75 | String attendeeEmail = "attendee@yourorg.com"; 76 | 77 | // Create an instance of the test class 78 | MeetingTest test = new MeetingTest(basePath, user, password); 79 | 80 | // Create an event 81 | String uid = test.createMeeting(folder, database, organizerEmail, attendeeEmail); 82 | 83 | if (uid != null) { 84 | // Read the event 85 | test.readMeeting(folder, database, uid); 86 | 87 | // Delete the event 88 | test.deleteMeeting(folder, database, uid); 89 | } 90 | 91 | } 92 | 93 | /** 94 | * Creates a meeting on the user's calendar. 95 | * 96 | * @param folder 97 | * @param database 98 | * @param organizerEmail 99 | * @param attendeeEmail 100 | * @return 101 | */ 102 | private String createMeeting(String folder, String database, String organizerEmail, String attendeeEmail) { 103 | String uid = null; 104 | Event event = new Event(); 105 | event.setSummary("API test"); 106 | event.setLocation("test"); 107 | event.setDescription("test"); 108 | 109 | ExDateTime start = new ExDateTime(); 110 | start.setDate("2018-01-01"); 111 | start.setTime("13:00:00"); 112 | start.setUtc(true); 113 | event.setStart(start); 114 | 115 | ExDateTime end = new ExDateTime(); 116 | end.setDate("2018-01-01"); 117 | end.setTime("14:00:00"); 118 | end.setUtc(true); 119 | event.setEnd(end); 120 | 121 | // A meeting must have an organizer 122 | Organizer organizer = new Organizer(); 123 | organizer.setEmail(organizerEmail); 124 | event.setOrganizer(organizer); 125 | 126 | // A meeting must have at least one attendee 127 | Attendee attendee = new Attendee(); 128 | attendee.setEmail(attendeeEmail); 129 | attendee.setRole("req-participant"); 130 | attendee.setStatus("needs-action"); 131 | attendee.setRsvp(true); 132 | event.getAttendees().add(attendee); 133 | 134 | EventRequest request = new EventRequest(); 135 | request.getEvents().add(event); 136 | 137 | try { 138 | 139 | // Create the event 140 | System.out.println("Creating an event in " + folder + "/" + database + " ..."); 141 | ApiResponse result = _eventApi.folderDatabaseApiCalendarEventsPostWithHttpInfo(folder, 142 | database, request, true); 143 | 144 | // Extract the Location header 145 | String location = null; 146 | Map> headers = result.getHeaders(); 147 | if (headers != null) { 148 | Set keys = headers.keySet(); 149 | for (String key : keys) { 150 | if (key.equalsIgnoreCase("Location")) { 151 | location = headers.get(key).get(0); 152 | break; 153 | } 154 | } 155 | } 156 | 157 | // Extract the UID from the location 158 | if (location != null) { 159 | // Dump the Location header 160 | System.out.println("Create event request succeeded. Location is " + location); 161 | 162 | int index = location.lastIndexOf('/'); 163 | if (index != -1) { 164 | uid = location.substring(index + 1, location.length()); 165 | } 166 | } 167 | else { 168 | // Unexpected response 169 | System.out.println("Create event request succeeded, but the response doesn't include a Location header."); 170 | } 171 | 172 | System.out.println(); 173 | } 174 | catch (ApiException e) { 175 | System.err.println("Exception when calling EventApi#folderDatabaseApiCalendarEventsPostWithHttpInfo"); 176 | String body = e.getResponseBody(); 177 | if (body != null) { 178 | System.err.println("Response from server ..."); 179 | System.err.println(body); 180 | } 181 | else { 182 | e.printStackTrace(); 183 | } 184 | } 185 | 186 | return uid; 187 | } 188 | 189 | /** 190 | * Reads a meeting and dumps it's properties to the console. 191 | * 192 | * @param folder 193 | * @param database 194 | * @param uid 195 | */ 196 | private void readMeeting(String folder, String database, String uid) { 197 | try { 198 | 199 | // Read the event 200 | System.out.println("Reading event " + uid + " from " + folder + "/" + database + " ..."); 201 | EventResponse result = _eventApi.folderDatabaseApiCalendarEventsUidGet(folder, database, uid, null); 202 | 203 | // Does the response have events? 204 | List events = result.getEvents(); 205 | if (events != null) { 206 | 207 | // Dump the events 208 | System.out.println("Read event request succeeded. Response follows ...\n"); 209 | for (int i = 0; i < events.size(); i++) { 210 | Event event = events.get(i); 211 | System.out.println("Event " + i); 212 | System.out.println(" summary: " + event.getSummary()); 213 | System.out.println(" location: " + event.getLocation()); 214 | System.out.println(" href: " + event.getHref()); 215 | 216 | String start = event.getStart().getDate(); 217 | if (event.getStart().getTime() != null) { 218 | start += "T" + event.getStart().getTime(); 219 | } 220 | System.out.println(" start: " + start); 221 | 222 | String end = event.getEnd().getDate(); 223 | if (event.getEnd().getTime() != null) { 224 | end += "T" + event.getEnd().getTime(); 225 | } 226 | System.out.println(" end: " + end); 227 | 228 | if (event.getOrganizer() == null) { 229 | System.err.println(" Event has no organizer!"); 230 | } 231 | else { 232 | System.out.println(" organizer: " + event.getOrganizer().getDisplayName()); 233 | } 234 | 235 | for (Attendee attendee : event.getAttendees()) { 236 | System.out.println(" attendee: " + attendee.getDisplayName() + "; " + attendee.getRole()); 237 | } 238 | 239 | System.out.println(" sequence: " + event.getSequence()); 240 | System.out.println(" description: " + event.getDescription()); 241 | 242 | if (event.getXLotusAppttype() == null || !"3".equals(event.getXLotusAppttype().getData())) { 243 | System.err.println(" x-lotus-appttype is missing or not equal to '3'"); 244 | } 245 | } 246 | } 247 | else { 248 | 249 | // Unexpected response 250 | System.out.println("Read event request succeeded, but the response doesn't include a list of events."); 251 | } 252 | } 253 | catch (ApiException e) { 254 | System.err.println("Exception when calling EventApi#folderDatabaseApiCalendarEventsUidGet"); 255 | String body = e.getResponseBody(); 256 | if (body != null) { 257 | System.err.println("Response from server ..."); 258 | System.err.println(body); 259 | } 260 | else { 261 | e.printStackTrace(); 262 | } 263 | } 264 | } 265 | 266 | /** 267 | * Deletes a meeting from the user's calendar. 268 | * 269 | * @param folder 270 | * @param database 271 | * @param uid 272 | */ 273 | private void deleteMeeting(String folder, String database, String uid) { 274 | try { 275 | 276 | // Delete the event 277 | System.out.println("Deleting event " + uid + " from " + folder + "/" + database + " ..."); 278 | _eventApi.folderDatabaseApiCalendarEventsUidDelete(folder, database, uid, true); 279 | 280 | } 281 | catch (ApiException e) { 282 | System.err.println("Exception when calling EventApi#folderDatabaseApiCalendarEventsUidDelete"); 283 | String body = e.getResponseBody(); 284 | if (body != null) { 285 | System.err.println("Response from server ..."); 286 | System.err.println(body); 287 | } 288 | else { 289 | e.printStackTrace(); 290 | } 291 | } 292 | } 293 | } 294 | --------------------------------------------------------------------------------