Created by gh-md-toc
- Usage
import { Auth, Statistics } from 'shifter-sdk'
const client = new Auth()
client.login('USERNAME', 'PASSWORD')
.then(result => console.log(result))
{
AccessToken: string,
RefreshToken: string
}
import { Auth, Statistics } from 'shifter-sdk'
const client = new Auth()
client.login('USERNAME', 'PASSWORD')
.then(({ AccessToken }) => {
const client = new Statistics.UsageSummary({
token: AccessToken
})
return client.describe()
})
.then(result => console.log(result))
{
updated_time: '2019-03-13T23:20:42.588404',
projects_count: 10,
disk_total: 10000,
transfer_total: 0,
user_name: 'hello',
track_month: 201903
}
import { Auth, Statistics } from 'shifter-sdk'
const client = new Auth()
client.login('USERNAME', 'PASSWORD')
.then(({ RefreshToken }) => {
return client.refresh(RefreshToken))
})
.then(result => console.log(result))
{
AccessToken: string
}
import { Statistics } from 'shifter-sdk'
const client = new Statistics.UsageSummary({
token: 'YOUR_TOKEN'
})
client.describe()
.then(result => console.log(result))
{
updated_time: '2019-03-13T23:20:42.588404',
projects_count: 10,
disk_total: 10000,
transfer_total: 0,
user_name: 'hello',
track_month: 201903
}
import { Statistics } from "shifter-sdk";
const client = new Statistics.SiteTransfer({
token: "YOUR_TOKEN",
});
const result = await client.describe(siteId)[
({
transfer_gb: 5,
track_month: 201902,
},
{
transfer_gb: 10,
track_month: 201903,
})
];
import { Sites } from "shifter-sdk";
const client = new Sites({
token: "ACCESS_TOKEN",
});
const sites = await client.list()[
{
project_name: "test",
stock_state: "inuse",
project_id: "xxxxx-xxxxx-xxxx",
project_owner: "xxxxx",
wordpress_site_url: null,
php_version: "7.2",
access_url: "xxxxxx.on.getshifter.io",
last_launched: "2019-02-18T03:14:59+00:00",
disk_usage: 4,
deploy_type: "shifter_cdn",
raw_url: "xxxxxx.cloudfront.net",
create_time: "2019-01-18T06:21:31+00:00",
automation: true,
}
];
const sites = await client.describe('site id')
{
"project_name": "test",
"stock_state": "inuse",
"project_id": "xxxxx-xxxxx-xxxx",
"project_owner": "xxxxx",
"wordpress_site_url": null,
"php_version": "7.2",
"access_url": "xxxxxx.on.getshifter.io",
"last_launched": "2019-02-18T03:14:59+00:00",
"disk_usage": 4,
"deploy_type": "shifter_cdn",
"raw_url": "xxxxxx.cloudfront.net",
"create_time": "2019-01-18T06:21:31+00:00",
"automation": true
}
const result = await client.create('my new site')
{
"project_id": "xxx-xxxx-xxxx-xxxx",
"project_name": "my new site",
"shifter_cdn_url": "xxxx.cloudfront.net"
}
await client.updateName(siteId, name);
("");
await client.enabledDeployAutomation(siteId);
("");
await client.disabledDeployAutomation(siteId);
("");
await client.startWordPress(siteId)
{
"notification_id": "xxxxxxxxxxxxxxxxxxx"
}
await client.startWordPressAsEmergency(siteId)
{
"notification_id": "xxxxxxxxxxxxxxxxxxx",
"emergency_password": "xxxxxxxxx"
}
const { notification_id } = await client.startWordPress(siteId);
const status = await client.getWPSetupStatus(siteId, notification_id);
("INITIALIZING");
await client.stopWordPress(siteId);
("");
await client.delete(siteId);
("");
import { Artifacts } from "shifter-sdk";
const client = new Artifacts({
token: "ACCESS_TOKEN",
});
Start to generate a new artifact
const sites = await client.generate(siteId)
{
"project_id":"xxxx-xxxxx-xxxxx-xxxx",
"artifact_id":"xxxx-xxxxx-xxxxx-xxxx"
}
await client.getDownloadURL(siteId, artifactId)
{
"url": "https://xxxxx"
}
await client.getGeneratingProcess(siteId)
{
"percent": null,
"sum_url": 0,
"created_url": 0,
"step": "queuing",
"update_time": "2019-02-18T03:16:21.760Z",
"owner": "john",
"message": "queuing",
"disk_usage": 4
}
const sites = await client.list()[
{
artifact_id: "xxx-xxxxx-xxxxx",
status: "published-shifter",
context_status: "success",
created_at: "2019-02-18T03:15:49+00:00",
failure_pages: "[]",
}
];
await Client.publish(siteId, artifactId);
("");
const sites = await client.stopGenerating(siteId, artifactId);
("");
const sites = await client.updateName(siteId, artifactId, name);
("");
await client.enablePreview(siteId, artifactId);
("https://xxxxx-xxxx-xxxxx-xxxx.preview.getshifter.io");
await client.delete(siteId, artifactId);
("");
import { Organizations } from "shifter-sdk";
const client = new Organizations.Foundation({
token: "ACCESS_TOKEN",
});
client
.create({
org_name: "organization name",
})
.then((result) => console.log(result));
{
org_id: "xxxxxxxxxxx";
}
client
.update("org_id", {
org_name: "organization name",
})
.then(() => console.log("ok"));
ok;
client.list().then((result) => console.log(result))[
{
org_id: "xxxxx-xxxx-xxxx-xxxx",
org_name: "xxxxx",
org_owner: "xxxxxxx",
org_website: "",
phone_number: "",
org_country: "",
org_state: "",
org_twitter: "",
org_size: "",
projects: [],
members: [],
}
];
client.descibe('org_id')
.then(result => console.log(result))
{
org_id: 'xxxxx-xxxx-xxxx-xxxx',
org_name: 'xxxxx',
org_owner: 'xxxxxxx',
org_website: '',
phone_number: '',
org_country: '',
org_state: '',
org_twitter: '',
org_size: '',
projects: [],
members: []
}
client.delete("org_id").then(() => console.log("ok"));
ok;
client.activateInvitation("org_id", "key").then(() => console.log("ok"));
ok;
import { Organizations } from "shifter-sdk";
const client = new Organizations.Sites({
token: "YOUR_TOKEN",
});
client.list("org_id").then((result) => console.log(result))[
{
project_name: "test-sub",
stock_state: "inuse",
project_id: "xxxx-xxxxxx-xxxxxx-xxxxxx",
project_owner: "xxxxxx",
php_version: "7.2",
access_url: "xxxxxxxxx.on.getshifter.io",
update_time: "",
last_launched: false,
disk_usage: 0,
deploy_type: false,
raw_url: "xxxxxxxxx.cloudfront.net",
create_time: "2018-07-05T07:41:25+00:00",
automation: false,
generate_state: "",
trial: "",
}
];
client.describe('org_id', 'site_id')
.then(result => console.log(result))
{
"project_name": "test-sub",
"stock_state": "inuse",
"project_id": "xxxx-xxxxxx-xxxxxx-xxxxxx",
"project_owner": "xxxxxx",
"php_version": "7.2",
"access_url": "xxxxxxxxx.on.getshifter.io",
"update_time": "",
"last_launched": false,
"disk_usage": 0,
"deploy_type": false,
"raw_url": "xxxxxxxxx.cloudfront.net",
"create_time": "2018-07-05T07:41:25+00:00",
"automation": false,
"generate_state": "",
"trial": ""
}
client.add("org_id", ["site_id"]).then(() => console.log("ok"));
ok;
client.remove("org_id", ["site_id"]).then(() => console.log("ok"));
ok;
import { Organizations } from "shifter-sdk";
const client = new Organizations.Members({
token: "YOUR_TOKEN",
});
client.list('org_id')
.then(result => console.log(result))
[
{
"username": "johndoe",
"email": "hhoge@example.com",
"user_status": "approval"
"role": "owner"
}
]
client
.add("org_id", "hoge@example.com", "username")
.then(() => console.log("ok"));
ok;
client.remove("org_id", ["username"]).then(() => console.log("ok"));
ok;
import { Status } from "shifter-sdk";
const client = new Status({
token: "YOUR_TOKEN",
});
client.descibe()
.then(result => console.log(result))
{ maintenance:
{ message:
'XXXXXXXXXXXx',
target: [ 'generator', 'container' ],
status: 'not_maintenance' },
user:
{ credit_card_status: 'registered',
upper_limit_projects: '50',
notification: { email: [Object] },
group: { name: 'owner' },
max_transfer_gb: '10240',
max_disk_gb: '1024',
domain_setting: 'true',
import_archives: 'true',
export_archives: 'true',
backup: '365',
enable_subuser: 'true',
export_artifact: 'true' } }
import { Webhooks } from "shifter-sdk";
const client = new Webhooks.Site({
token: "YOUR_TOKEN",
});
const result = await client.create(siteId, [
{
hook_event: "Webhook:Artifact:Created",
url: "https://hoge.example.com",
enabled: false,
headers: {},
method: "post",
},
])[
{
enabled: false,
hook_event: "Webhook:Artifact:Created#d34c85ad-d50a-4efe-a52a-1023b30e37ed",
webhook_url: "https://hoge.example.com",
headers: {},
method: "post",
site_id: "bfd1fbde-8f01-11e8-aa52-9ad4a0753b52",
}
];
const result = await client.update(siteId, [
{
hook_event: "Webhook:Artifact:Created#d34c85ad-d50a-4efe-a52a-1023b30e37ed",
url: "https://hoge.example.com",
enabled: true,
headers: { "x-test": "hoge" },
method: "post",
},
])[
{
enabled: true,
hook_event: "Webhook:Artifact:Created#d34c85ad-d50a-4efe-a52a-1023b30e37ed",
webhook_url: "https://hoge.example.com",
headers: { "x-test": "hoge" },
method: "post",
site_id: "bfd1fbde-8f01-11e8-aa52-9ad4a0753b52",
}
];
const result = await client.list(siteId)[
{
enabled: false,
hook_event: "Webhook:Artifact:Created#d34c85ad-d50a-4efe-a52a-1023b30e37ed",
webhook_url: "https://hoge.example.com",
headers: {},
method: "post",
site_id: "bfd1fbde-8f01-11e8-aa52-9ad4a0753b52",
}
];
const result = await client.delete(siteId, [
{
hook_event: "Webhook:Artifact:Created#d34c85ad-d50a-4efe-a52a-1023b30e37ed",
},
]);
("");