Skip to content

Commit 59abf1c

Browse files
committed
updated read me file
1 parent c296c35 commit 59abf1c

File tree

2 files changed

+54
-16
lines changed

2 files changed

+54
-16
lines changed

.changeset/five-badgers-yawn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"cloudways-js-client": patch
3+
---
4+
5+
updated read me file

README.md

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,61 @@ Please note that this library is still under development. Although it's function
3636
<pre><code>npm install cloudways-js-client
3737
</code></pre>
3838

39-
<h2>Usage</h2>
39+
<h2>Usage</h2>
40+
<p>The Cloudways JS Client library makes it easy to interact with the Cloudways API for various operations. Below are some examples to help you get started.</p>
4041

41-
<p>
42-
To get you started, here's an example that demonstrates how to get the status of a background operation using the "Get Operation Status" function:
43-
</p>
42+
<h3>Initializing the API</h3>
43+
<p>Before performing any operations, initialize the API with your Cloudways account credentials:</p>
44+
<div class="code-title">JavaScript:</div>
45+
<pre><code>import { initializeCloudwaysApi } from 'cloudways-js-client';
4446

45-
<pre><code>import { getOperationStatus, GetOperationStatusRequest } from 'cloudways-js-client';
47+
const email = '[email protected]'; // Replace with your Cloudways account email
48+
const apiKey = 'your_api_key'; // Replace with your Cloudways API key
49+
50+
initializeCloudwaysApi(email, apiKey);
51+
</code></pre>
52+
53+
<h3>Deleting a Server</h3>
54+
<p>To delete a server, use the <code>deleteServer</code> function. Ensure you have the correct server ID:</p>
55+
<div class="code-title">JavaScript:</div>
56+
<pre><code>import { deleteServer } from 'cloudways-js-client';
57+
58+
async function deleteServerA() {
59+
const serverId = 12345; // Replace with the server ID you want to delete
60+
await deleteServer(serverId);
61+
console.log('Server deleted successfully.');
62+
}
63+
</code></pre>
64+
65+
<h3>Getting the List of Servers</h3>
66+
<p>You can retrieve the list of servers associated with your account using the <code>getServersList</code> function:</p>
67+
<div class="code-title">JavaScript:</div>
68+
<pre><code>import { getServersList } from 'cloudways-js-client';
69+
70+
async function listServers() {
71+
try {
72+
const servers = await getServersList();
73+
console.log('Servers List:', servers);
74+
} catch (error) {
75+
console.error('Error fetching servers list:', error);
76+
}
77+
}
78+
79+
listServers();
80+
</code></pre>
4681

47-
const payload: GetOperationStatusRequest = {
48-
id: 123456 // Replace with the operation ID you have
49-
};
82+
<h3>Combining Operations</h3>
83+
<p>You can combine these functions to perform multiple operations. For example, to delete a server and then get the updated list of servers:</p>
84+
<div class="code-title">JavaScript:</div>
85+
<pre><code>async function deleteServerAndGetList() {
5086

51-
async function fetchOperationStatus() {
52-
try {
53-
const response = await getOperationStatus(payload);
54-
console.log("Operation Status:", response.operation);
55-
} catch (error) {
56-
console.error("Error fetching operation status:", error);
57-
}
87+
const serverId = 12345; // Replace with the server ID to delete
88+
await deleteServer(serverId);
89+
console.log('Server deleted successfully.');
90+
console.log('Updated Servers List:', await getServersList());
5891
}
5992

60-
fetchOperationStatus();
93+
deleteServerAndGetList();
6194
</code></pre>
6295

6396
<p>For detailed usage examples and API documentation, please refer to the <a href="https://developers.cloudways.com/docs/">documentation</a>.</p>

0 commit comments

Comments
 (0)