Skip to content

Commit 62dc349

Browse files
authored
Merge pull request #2 from kubernetes-incubator/o2
Client enhancements
2 parents d67df30 + 273684c commit 62dc349

File tree

369 files changed

+59863
-25935
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

369 files changed

+59863
-25935
lines changed

.swagger-codegen-ignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
.gitignore
22
git_push.sh
3+
test/*
4+
requirements.txt
5+
setup.py

GEN_README.md

Lines changed: 0 additions & 846 deletions
This file was deleted.

README.md

Lines changed: 938 additions & 5 deletions
Large diffs are not rendered by default.

README.prefix

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Kubernetes Python Client
2+
3+
Python clients for talking to a [kubernetes](http://kubernetes.io/) cluster.
4+
5+
## Example
6+
7+
list all pods:
8+
9+
```python
10+
import k8sutil
11+
import k8sclient
12+
import os
13+
14+
# Configs can be set in Configuration class directly or using helper utility
15+
k8sutil.load_kube_config(os.environ["HOME"] + '/.kube/config')
16+
17+
v1=k8sclient.CoreV1Api()
18+
print("Listing pods with their IPs:")
19+
ret = v1.list_pod_for_all_namespaces(watch=False)
20+
for i in ret.items:
21+
print("%s\t%s\t%s" % (i.status.pod_ip, i.metadata.namespace, i.metadata.name))
22+
```
23+
24+
watch on namespace object:
25+
26+
```python
27+
import k8sutil
28+
import k8sclient
29+
import os
30+
31+
32+
# Configs can be set in Configuration class directly or using helper utility
33+
k8sutil.load_kube_config(os.environ["HOME"] + '/.kube/config')
34+
35+
v1 = k8sclient.CoreV1Api()
36+
count = 10
37+
watch = k8sutil.Watch()
38+
for event in watch.stream(v1.list_namespace, _request_timeout=60):
39+
print("Event: %s %s" % (event['type'], event['object'].metadata.name))
40+
count -= 1
41+
if not count:
42+
watch.stop()
43+
44+
print("Ended.")
45+
```
46+
47+
More examples can be found in [examples](examples/) folder. To run examples, run this command:
48+
49+
```shell
50+
python -m examples.example1
51+
```
52+
53+
(replace example1 with the example base filename)
54+
55+
56+
# Generated client README
57+
58+

docs/AppsApi.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ All URIs are relative to *https://localhost*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
7-
[**get_apps_api_group**](AppsApi.md#get_apps_api_group) | **GET** /apis/apps/ |
7+
[**get_api_group**](AppsApi.md#get_api_group) | **GET** /apis/apps/ |
88

99

10-
# **get_apps_api_group**
11-
> UnversionedAPIGroup get_apps_api_group()
10+
# **get_api_group**
11+
> UnversionedAPIGroup get_api_group()
1212
1313

1414

@@ -31,10 +31,10 @@ k8sclient.configuration.api_key['authorization'] = 'YOUR_API_KEY'
3131
api_instance = k8sclient.AppsApi()
3232

3333
try:
34-
api_response = api_instance.get_apps_api_group()
34+
api_response = api_instance.get_api_group()
3535
pprint(api_response)
3636
except ApiException as e:
37-
print("Exception when calling AppsApi->get_apps_api_group: %s\n" % e)
37+
print("Exception when calling AppsApi->get_api_group: %s\n" % e)
3838
```
3939

4040
### Parameters

docs/AppsV1alpha1Api.md renamed to docs/AppsV1beta1Api.md

Lines changed: 110 additions & 106 deletions
Large diffs are not rendered by default.

docs/AuthenticationApi.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ All URIs are relative to *https://localhost*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
7-
[**get_authentication_api_group**](AuthenticationApi.md#get_authentication_api_group) | **GET** /apis/authentication.k8s.io/ |
7+
[**get_api_group**](AuthenticationApi.md#get_api_group) | **GET** /apis/authentication.k8s.io/ |
88

99

10-
# **get_authentication_api_group**
11-
> UnversionedAPIGroup get_authentication_api_group()
10+
# **get_api_group**
11+
> UnversionedAPIGroup get_api_group()
1212
1313

1414

@@ -31,10 +31,10 @@ k8sclient.configuration.api_key['authorization'] = 'YOUR_API_KEY'
3131
api_instance = k8sclient.AuthenticationApi()
3232

3333
try:
34-
api_response = api_instance.get_authentication_api_group()
34+
api_response = api_instance.get_api_group()
3535
pprint(api_response)
3636
except ApiException as e:
37-
print("Exception when calling AuthenticationApi->get_authentication_api_group: %s\n" % e)
37+
print("Exception when calling AuthenticationApi->get_api_group: %s\n" % e)
3838
```
3939

4040
### Parameters

docs/AuthenticationV1beta1Api.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ All URIs are relative to *https://localhost*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
7-
[**create_authentication_v1beta1_token_review**](AuthenticationV1beta1Api.md#create_authentication_v1beta1_token_review) | **POST** /apis/authentication.k8s.io/v1beta1/tokenreviews |
8-
[**get_authentication_v1beta1_api_resources**](AuthenticationV1beta1Api.md#get_authentication_v1beta1_api_resources) | **GET** /apis/authentication.k8s.io/v1beta1/ |
7+
[**create_token_review**](AuthenticationV1beta1Api.md#create_token_review) | **POST** /apis/authentication.k8s.io/v1beta1/tokenreviews |
8+
[**get_api_resources**](AuthenticationV1beta1Api.md#get_api_resources) | **GET** /apis/authentication.k8s.io/v1beta1/ |
99

1010

11-
# **create_authentication_v1beta1_token_review**
12-
> V1beta1TokenReview create_authentication_v1beta1_token_review(body, pretty=pretty)
11+
# **create_token_review**
12+
> V1beta1TokenReview create_token_review(body, pretty=pretty)
1313
1414

1515

@@ -34,10 +34,10 @@ body = k8sclient.V1beta1TokenReview() # V1beta1TokenReview |
3434
pretty = 'pretty_example' # str | If 'true', then the output is pretty printed. (optional)
3535

3636
try:
37-
api_response = api_instance.create_authentication_v1beta1_token_review(body, pretty=pretty)
37+
api_response = api_instance.create_token_review(body, pretty=pretty)
3838
pprint(api_response)
3939
except ApiException as e:
40-
print("Exception when calling AuthenticationV1beta1Api->create_authentication_v1beta1_token_review: %s\n" % e)
40+
print("Exception when calling AuthenticationV1beta1Api->create_token_review: %s\n" % e)
4141
```
4242

4343
### Parameters
@@ -62,8 +62,8 @@ Name | Type | Description | Notes
6262

6363
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
6464

65-
# **get_authentication_v1beta1_api_resources**
66-
> UnversionedAPIResourceList get_authentication_v1beta1_api_resources()
65+
# **get_api_resources**
66+
> UnversionedAPIResourceList get_api_resources()
6767
6868

6969

@@ -86,10 +86,10 @@ k8sclient.configuration.api_key['authorization'] = 'YOUR_API_KEY'
8686
api_instance = k8sclient.AuthenticationV1beta1Api()
8787

8888
try:
89-
api_response = api_instance.get_authentication_v1beta1_api_resources()
89+
api_response = api_instance.get_api_resources()
9090
pprint(api_response)
9191
except ApiException as e:
92-
print("Exception when calling AuthenticationV1beta1Api->get_authentication_v1beta1_api_resources: %s\n" % e)
92+
print("Exception when calling AuthenticationV1beta1Api->get_api_resources: %s\n" % e)
9393
```
9494

9595
### Parameters

docs/AuthorizationApi.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ All URIs are relative to *https://localhost*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
7-
[**get_authorization_api_group**](AuthorizationApi.md#get_authorization_api_group) | **GET** /apis/authorization.k8s.io/ |
7+
[**get_api_group**](AuthorizationApi.md#get_api_group) | **GET** /apis/authorization.k8s.io/ |
88

99

10-
# **get_authorization_api_group**
11-
> UnversionedAPIGroup get_authorization_api_group()
10+
# **get_api_group**
11+
> UnversionedAPIGroup get_api_group()
1212
1313

1414

@@ -31,10 +31,10 @@ k8sclient.configuration.api_key['authorization'] = 'YOUR_API_KEY'
3131
api_instance = k8sclient.AuthorizationApi()
3232

3333
try:
34-
api_response = api_instance.get_authorization_api_group()
34+
api_response = api_instance.get_api_group()
3535
pprint(api_response)
3636
except ApiException as e:
37-
print("Exception when calling AuthorizationApi->get_authorization_api_group: %s\n" % e)
37+
print("Exception when calling AuthorizationApi->get_api_group: %s\n" % e)
3838
```
3939

4040
### Parameters

docs/AuthorizationV1beta1Api.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ All URIs are relative to *https://localhost*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
7-
[**create_authorization_v1beta1_namespaced_local_subject_access_review**](AuthorizationV1beta1Api.md#create_authorization_v1beta1_namespaced_local_subject_access_review) | **POST** /apis/authorization.k8s.io/v1beta1/namespaces/{namespace}/localsubjectaccessreviews |
8-
[**create_authorization_v1beta1_self_subject_access_review**](AuthorizationV1beta1Api.md#create_authorization_v1beta1_self_subject_access_review) | **POST** /apis/authorization.k8s.io/v1beta1/selfsubjectaccessreviews |
9-
[**create_authorization_v1beta1_subject_access_review**](AuthorizationV1beta1Api.md#create_authorization_v1beta1_subject_access_review) | **POST** /apis/authorization.k8s.io/v1beta1/subjectaccessreviews |
10-
[**get_authorization_v1beta1_api_resources**](AuthorizationV1beta1Api.md#get_authorization_v1beta1_api_resources) | **GET** /apis/authorization.k8s.io/v1beta1/ |
7+
[**create_namespaced_local_subject_access_review**](AuthorizationV1beta1Api.md#create_namespaced_local_subject_access_review) | **POST** /apis/authorization.k8s.io/v1beta1/namespaces/{namespace}/localsubjectaccessreviews |
8+
[**create_self_subject_access_review**](AuthorizationV1beta1Api.md#create_self_subject_access_review) | **POST** /apis/authorization.k8s.io/v1beta1/selfsubjectaccessreviews |
9+
[**create_subject_access_review**](AuthorizationV1beta1Api.md#create_subject_access_review) | **POST** /apis/authorization.k8s.io/v1beta1/subjectaccessreviews |
10+
[**get_api_resources**](AuthorizationV1beta1Api.md#get_api_resources) | **GET** /apis/authorization.k8s.io/v1beta1/ |
1111

1212

13-
# **create_authorization_v1beta1_namespaced_local_subject_access_review**
14-
> V1beta1LocalSubjectAccessReview create_authorization_v1beta1_namespaced_local_subject_access_review(body, namespace, pretty=pretty)
13+
# **create_namespaced_local_subject_access_review**
14+
> V1beta1LocalSubjectAccessReview create_namespaced_local_subject_access_review(body, namespace, pretty=pretty)
1515
1616

1717

@@ -37,10 +37,10 @@ namespace = 'namespace_example' # str | object name and auth scope, such as for
3737
pretty = 'pretty_example' # str | If 'true', then the output is pretty printed. (optional)
3838

3939
try:
40-
api_response = api_instance.create_authorization_v1beta1_namespaced_local_subject_access_review(body, namespace, pretty=pretty)
40+
api_response = api_instance.create_namespaced_local_subject_access_review(body, namespace, pretty=pretty)
4141
pprint(api_response)
4242
except ApiException as e:
43-
print("Exception when calling AuthorizationV1beta1Api->create_authorization_v1beta1_namespaced_local_subject_access_review: %s\n" % e)
43+
print("Exception when calling AuthorizationV1beta1Api->create_namespaced_local_subject_access_review: %s\n" % e)
4444
```
4545

4646
### Parameters
@@ -66,8 +66,8 @@ Name | Type | Description | Notes
6666

6767
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
6868

69-
# **create_authorization_v1beta1_self_subject_access_review**
70-
> V1beta1SelfSubjectAccessReview create_authorization_v1beta1_self_subject_access_review(body, pretty=pretty)
69+
# **create_self_subject_access_review**
70+
> V1beta1SelfSubjectAccessReview create_self_subject_access_review(body, pretty=pretty)
7171
7272

7373

@@ -92,10 +92,10 @@ body = k8sclient.V1beta1SelfSubjectAccessReview() # V1beta1SelfSubjectAccessRevi
9292
pretty = 'pretty_example' # str | If 'true', then the output is pretty printed. (optional)
9393

9494
try:
95-
api_response = api_instance.create_authorization_v1beta1_self_subject_access_review(body, pretty=pretty)
95+
api_response = api_instance.create_self_subject_access_review(body, pretty=pretty)
9696
pprint(api_response)
9797
except ApiException as e:
98-
print("Exception when calling AuthorizationV1beta1Api->create_authorization_v1beta1_self_subject_access_review: %s\n" % e)
98+
print("Exception when calling AuthorizationV1beta1Api->create_self_subject_access_review: %s\n" % e)
9999
```
100100

101101
### Parameters
@@ -120,8 +120,8 @@ Name | Type | Description | Notes
120120

121121
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
122122

123-
# **create_authorization_v1beta1_subject_access_review**
124-
> V1beta1SubjectAccessReview create_authorization_v1beta1_subject_access_review(body, pretty=pretty)
123+
# **create_subject_access_review**
124+
> V1beta1SubjectAccessReview create_subject_access_review(body, pretty=pretty)
125125
126126

127127

@@ -146,10 +146,10 @@ body = k8sclient.V1beta1SubjectAccessReview() # V1beta1SubjectAccessReview |
146146
pretty = 'pretty_example' # str | If 'true', then the output is pretty printed. (optional)
147147

148148
try:
149-
api_response = api_instance.create_authorization_v1beta1_subject_access_review(body, pretty=pretty)
149+
api_response = api_instance.create_subject_access_review(body, pretty=pretty)
150150
pprint(api_response)
151151
except ApiException as e:
152-
print("Exception when calling AuthorizationV1beta1Api->create_authorization_v1beta1_subject_access_review: %s\n" % e)
152+
print("Exception when calling AuthorizationV1beta1Api->create_subject_access_review: %s\n" % e)
153153
```
154154

155155
### Parameters
@@ -174,8 +174,8 @@ Name | Type | Description | Notes
174174

175175
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
176176

177-
# **get_authorization_v1beta1_api_resources**
178-
> UnversionedAPIResourceList get_authorization_v1beta1_api_resources()
177+
# **get_api_resources**
178+
> UnversionedAPIResourceList get_api_resources()
179179
180180

181181

@@ -198,10 +198,10 @@ k8sclient.configuration.api_key['authorization'] = 'YOUR_API_KEY'
198198
api_instance = k8sclient.AuthorizationV1beta1Api()
199199

200200
try:
201-
api_response = api_instance.get_authorization_v1beta1_api_resources()
201+
api_response = api_instance.get_api_resources()
202202
pprint(api_response)
203203
except ApiException as e:
204-
print("Exception when calling AuthorizationV1beta1Api->get_authorization_v1beta1_api_resources: %s\n" % e)
204+
print("Exception when calling AuthorizationV1beta1Api->get_api_resources: %s\n" % e)
205205
```
206206

207207
### Parameters

0 commit comments

Comments
 (0)