Skip to content

Commit f19118e

Browse files
committed
First generated client
1 parent f422fd0 commit f19118e

File tree

1,087 files changed

+185148
-1
lines changed

Some content is hidden

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

1,087 files changed

+185148
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tmp/

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
# javascript
2-
Javascript client
2+
3+
Javascript client. Work in progress.
4+
5+
6+
#Update client
7+
8+
to update the client clone `gen` repo and run this command:
9+
10+
${GEN_REPO_BASE}/openapi/javascript.sh ${CLIENT_ROOT}/kubernetes ./settings
11+

examples/client.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
'use strict'
2+
3+
const fs = require('fs');
4+
const parseArgs = require('minimist');
5+
const demoType = parseArgs(process.argv.slice(2));
6+
7+
// Location of custom CA crt
8+
const ca = fs.readFileSync(__dirname + '/ca.crt');
9+
10+
// Unwise option to turn off all TLS security in NodeJS. NodeJS uses a predefined list of trusted CAs and ignores the system CA store. Workaround was to append CA/cert/keys in ApiClient modification.
11+
// process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
12+
const kubernetes = require('./index');
13+
// UnversionedPatch model file was not generated, so a stub was put in.
14+
15+
const apiClient = new kubernetes.ApiClient();
16+
apiClient.ca = ca;
17+
apiClient.basePath = 'https://192.168.99.100:8443';
18+
// Authorization of personal minikube setup - not considered a security concern due to local nature - in actual use should be provided by user.
19+
apiClient.defaultHeaders = {
20+
"Authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhdWx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6ImRlZmF1bHQtdG9rZW4ta24wMHMiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGVmYXVsdCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6Ijk3MTBkNjc3LWRjNjctMTFlNi05NWMyLTA4MDAyNzY4YjNlYiIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDpkZWZhdWx0OmRlZmF1bHQifQ.RqeMeu3zxYqfGHpDV0vlVjG8EYgp_dG4Dr8dNc9zN-5J-tUOE_lBJ5VUWwh08GpN7jL3L66IZJ-zmJevVj7bd3OZBaGGTrEzgCrfuyrLIuPY-af8rZkElAtEaFdiT0m-z7JQqpUJ0yz9cZcOHiKN3vLR9zB7kVYcDWvMPwzzJsP65gPQptU1mRcx7w0wPtO8OmQXkrwrxoySwJpj7ug4Qv-QAIW9_Xa67qUUtKNaP1lgRIt9r4UL1fOrzS0fDNgBQClQ3CupkKRFQ4q7nvp6GkE-8HGzIg4tG65khfD2i750InZHGFZhLCTFmjiS-bmXx-MezEPb5rJ4rovMXcWj9w"
21+
};
22+
23+
// Core test
24+
25+
const core = new kubernetes.CoreApi(apiClient);
26+
const coreApi = new kubernetes.CorevApi(apiClient);
27+
const extensions = new kubernetes.ExtensionsvbetaApi(apiClient);
28+
const version = new kubernetes.VersionApi(apiClient);
29+
30+
// Versions
31+
if (demoType['v']) {
32+
core.getCoreAPIVersions(function(error, data, response) {
33+
console.log(error, data);
34+
});
35+
36+
version.getCodeVersion(function(error, data, response) {
37+
console.log(error, data);
38+
});
39+
}
40+
41+
// Test creation of namespace and deployment
42+
if (demoType['c']) {
43+
const testNs = "{\"kind\":\"Namespace\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"client-test\",\"creationTimestamp\":null},\"spec\":{},\"status\":{}}\n";
44+
coreApi.createCoreV1Namespace(testNs, {}, function(error, data, response) {
45+
console.log(error, data);
46+
});
47+
48+
49+
const testDep = "{\"kind\":\"Deployment\",\"apiVersion\":\"extensions/v1beta1\",\"metadata\":{\"name\":\"hello-world\",\"creationTimestamp\":null,\"labels\":{\"run\":\"hello-world\"}},\"spec\":{\"replicas\":1,\"selector\":{\"matchLabels\":{\"run\":\"hello-world\"}},\"template\":{\"metadata\":{\"creationTimestamp\":null,\"labels\":{\"run\":\"hello-world\"}},\"spec\":{\"containers\":[{\"name\":\"hello-world\",\"image\":\"hello-world\",\"ports\":[{\"containerPort\":8080}],\"resources\":{}}]}},\"strategy\":{}},\"status\":{}}\n";
50+
const deployment = kubernetes.V1beta1Deployment.constructFromObject(JSON.parse(testDep));
51+
52+
extensions.createExtensionsV1beta1NamespacedDeployment('default', JSON.stringify(deployment), {pretty: false}, function(error, data, response) {
53+
console.log(error, data);
54+
});
55+
56+
}
57+
58+
59+
// Read deployment
60+
if (demoType['r']) {
61+
extensions.listExtensionsV1beta1NamespacedDeployment('default', {pretty: false}, function(error, data, response) {
62+
console.log(error, data);
63+
});
64+
65+
extensions.readExtensionsV1beta1NamespacedDeployment('hello-world', 'default', {pretty: false}, function(error, data, response) {
66+
console.log(error, data);
67+
});
68+
}
69+
70+
// TEARDOWN
71+
if (demoType['d']) {
72+
const testDel = "{\"kind\":\"DeleteOptions\",\"apiVersion\":\"extensions/v1beta1\",\"orphanDependents\":false}\n";
73+
const delopts = kubernetes.V1beta1Deployment.constructFromObject(JSON.parse(testDel));
74+
extensions.deleteExtensionsV1beta1NamespacedDeployment('hello-world', 'default', JSON.stringify(delopts), {pretty: false}, function(error, data, response) {
75+
console.log(error, data);
76+
});
77+
78+
const delTestNs = "{\"kind\":\"DeleteOptions\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"client-test\",\"deletionGracePeriodSeconds\":\"60\"},\"spec\":{},\"status\":{}}\n";
79+
coreApi.deleteCoreV1Namespace('client-test', delTestNs, {}, function(error, data, response) {
80+
console.log(error, data);
81+
});
82+
}

kubernetes/.swagger-codegen-ignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Swagger Codegen Ignore
2+
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md

kubernetes/.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: node_js
2+
node_js:
3+
- "6"
4+
- "6.1"
5+
- "5"
6+
- "5.11"
7+

0 commit comments

Comments
 (0)