Skip to content

Commit 405b851

Browse files
authored
feat: add code samples for Versions and EnvVars (#1335)
1 parent 5a36160 commit 405b851

10 files changed

+124
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
await apifyClient
7+
.actor('<ACTOR ID>')
8+
.version('0.1')
9+
.delete();
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
await apifyClient
7+
.actor('<ACTOR ID>')
8+
.version('0.1')
9+
.envVar('MY_ENV_VAR')
10+
.delete();
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const envVar = await apifyClient
7+
.actor('<ACTOR ID>')
8+
.version('0.1')
9+
.envVar('MY_ENV_VAR')
10+
.get();
11+
12+
console.log(envVar);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const updatedEnvVar = await apifyClient
7+
.actor('<ACTOR ID>')
8+
.version('0.1')
9+
.envVar('MY_ENV_VAR')
10+
.update({
11+
name: 'MY_ENV_VAR',
12+
value: 'my-new-value',
13+
});
14+
15+
console.log(updatedEnvVar);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const { items } = await apifyClient
7+
.actor('<ACTOR ID>')
8+
.version('0.1')
9+
.envVars()
10+
.list();
11+
12+
console.log(items);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const envVar = await apifyClient
7+
.actor('<ACTOR ID>')
8+
.version('0.1')
9+
.envVars()
10+
.create({
11+
name: 'MY_ENV_VAR',
12+
value: 'my-new-value',
13+
isSecret: true,
14+
});
15+
16+
console.log(envVar);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const version = await apifyClient
7+
.actor('<ACTOR ID>')
8+
.version('0.1')
9+
.get();
10+
11+
console.log(version);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const updatedVersion = await apifyClient
7+
.actor('<ACTOR ID>')
8+
.version('0.1')
9+
.update({
10+
buildTag: 'latest',
11+
});
12+
13+
console.log(updatedVersion);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const { items } = await apifyClient
7+
.actor('<ACTOR ID>')
8+
.versions()
9+
.list();
10+
11+
console.log(items);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({
4+
token: '<TOKEN>',
5+
});
6+
const version = await apifyClient
7+
.actor('<ACTOR ID>')
8+
.versions()
9+
.create({
10+
versionNumber: '0.1',
11+
sourceType: 'GIT_REPO',
12+
gitRepoUrl: 'https://github.com/my/repo',
13+
});
14+
15+
console.log(version);

0 commit comments

Comments
 (0)