How To Get A Single Instance Details
Open
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 273
- Forks
- 391
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
How t get single instance details?
I could not find how to get a single instance using the api in the documentation. I am now fetching all instances and making a filter function to retrieve one instance, which is not optimal.
/**
* @param {{
* instancePrefix: string;
* region: string;
* }} param0
* @returns {Promise<
* {
* name: string | undefined;
* id: string | undefined;
* status: string | undefined;
* ip: string | undefined;
* }[]
* >}
*/
async getInstancesFromProvider({ instancePrefix, region }) {
try {
const token = await getOSToken();
// get current region
const url_splitted = config.openstack.servers_url.split(".");
url_splitted[1] = region.toLowerCase();
const url = url_splitted.join(".");
const headers = {
"X-Auth-Token": token,
};
const response = await axios.get(url, { headers });
// get instances array
let instances = response.data.servers;
// format return output
instances = this.processInstancesFromOpenstack(instances);
// retrive one instance using js filter function :/
let instancesOS = instances.filter((instanceOS) => instanceOS.name.includes(instancePrefix));
return instancesOS;
} catch (error) {
console.log(error);
throw new CustomApiError("ovh.get-instances-error", {
originalError: error,
});
}
}
config
openstack: {
token_url: "https://auth.cloud.ovh.net/v3/auth/tokens",
token_payload: {
auth: {
identity: {
methods: ["password"],
password: {
user: {
name: "<name>",
domain: {
name: "Default",
},
password: "<password>",
},
},
},
scope: {
project: {
id: "project_id",
},
},
},
},
servers_url: "https://compute.de1.cloud.ovh.net/v2.1/<project_id>/servers/detail",
},
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked OpenStack server concepts documentation and the getInstancesFromProvider entry point shown in the issue. Determine what documentation is missing about retrieving one instance rather than listing all servers; done means the documented guidance clearly covers the requested lookup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- cloud, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100