Skip to content

Commit e14dd96

Browse files
committed
📝 docs: Put documentation outside the readme file
1 parent 4bacb6c commit e14dd96

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

docs/examples.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
## 🚀 Usage
2+
3+
Basic usage with the default profile:
4+
5+
```python
6+
from osc_sdk_python import Gateway
7+
8+
gw = Gateway()
9+
10+
# Example: list VMs
11+
vms = gw.ReadVms()
12+
print(vms)
13+
```
14+
15+
Using a specific profile:
16+
17+
```python
18+
from osc_sdk_python import Gateway
19+
20+
gw = Gateway(profile="profile_1")
21+
```
22+
23+
Calling actions:
24+
25+
* **Typed methods**: `gw.ReadVms(...)`, `gw.CreateVms(...)`, etc.
26+
* **Raw calls**: `gw.raw("ActionName", **params)`
27+
28+
Example:
29+
30+
```python
31+
from osc_sdk_python import Gateway
32+
33+
gw = Gateway(profile="profile_1")
34+
35+
# Calls with API action as method
36+
result = gw.ReadSecurityGroups(Filters={"SecurityGroupNames": ["default"]})
37+
result = gw.CreateVms(ImageId="ami-3e158364", VmType="tinav4.c2r4")
38+
39+
# Or raw calls:
40+
result = gw.raw("ReadVms")
41+
result = gw.raw(
42+
"CreateVms",
43+
ImageId="ami-xx",
44+
BlockDeviceMappings=[{"/dev/sda1": {"Size": 10}}],
45+
SecurityGroupIds=["sg-aaa", "sg-bbb"],
46+
Wrong="wrong",
47+
)
48+
```
49+
50+
---
51+
52+
## 💡 Examples
53+
54+
### List all VM and Volume IDs
55+
56+
```python
57+
from osc_sdk_python import Gateway
58+
59+
if __name__ == "__main__":
60+
gw = Gateway()
61+
62+
print("Your virtual machines:")
63+
for vm in gw.ReadVms()["Vms"]:
64+
print(vm["VmId"])
65+
66+
print("\nYour volumes:")
67+
for volume in gw.ReadVolumes()["Volumes"]:
68+
print(volume["VolumeId"])
69+
```
70+
71+
### Enabling logs
72+
73+
```python
74+
from osc_sdk_python import *
75+
76+
if __name__ == "__main__":
77+
gw = Gateway(profile="profile_1")
78+
79+
# 'what' can be LOG_KEEP_ONLY_LAST_REQ or LOG_ALL
80+
# Here we print logs in memory, standard output and standard error
81+
gw.log.config(type=LOG_MEMORY | LOG_STDIO | LOG_STDERR, what=LOG_KEEP_ONLY_LAST_REQ)
82+
83+
result = gw.raw("ReadVms")
84+
85+
last_request = gw.log.str()
86+
print(last_request)
87+
```
88+
89+
Usage examples can be combined with the official [Outscale API documentation](https://docs.outscale.com/en/userguide/Home.html).

docs/troubleshooting.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## ⚠️ Known Issues & Troubleshooting
2+
3+
### UTF-8 errors when reading the API specification
4+
5+
Some users may encounter UTF-8 issues that look like this:
6+
7+
```bash
8+
Problem reading (…)osc_sdk_python/osc-api/outscale.yaml:'ascii' codec can't decode byte 0xe2 in position 14856: ordinal not in range(128)
9+
```
10+
11+
To avoid this issue, configure your locale as follows:
12+
13+
```bash
14+
export LC_ALL=en_US.UTF-8
15+
```
16+
17+
If you do not want your locale to be set system-wide, you can do:
18+
19+
```bash
20+
LC_ALL=en_US.UTF-8 pip install osc-sdk-python
21+
```

0 commit comments

Comments
 (0)