attlaz-client 1.9.33 → 1.9.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,12 @@
1
- export declare class CodeSource {
1
+ import { StateAware } from '../StateAware';
2
+ import { State } from '../State';
3
+ export declare class CodeSource implements StateAware {
2
4
  id: string;
3
5
  codeSourceAccountId: string;
4
6
  repository: string;
5
7
  branch: string;
6
8
  platformId: string;
7
9
  buildStrategyId: string;
10
+ state: State;
8
11
  static parse(rawCodeSource: any): CodeSource;
9
12
  }
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CodeSource = void 0;
4
+ const State_1 = require("../State");
4
5
  class CodeSource {
6
+ constructor() {
7
+ this.state = State_1.State.Active;
8
+ }
5
9
  static parse(rawCodeSource) {
6
10
  let codeSource = new CodeSource();
7
11
  codeSource.id = rawCodeSource.id;
@@ -10,6 +14,7 @@ class CodeSource {
10
14
  codeSource.branch = rawCodeSource.branch;
11
15
  codeSource.platformId = rawCodeSource.platform;
12
16
  codeSource.buildStrategyId = rawCodeSource.build_strategy;
17
+ codeSource.state = State_1.State.fromString(rawCodeSource.state);
13
18
  return codeSource;
14
19
  }
15
20
  }
@@ -10,4 +10,5 @@ export declare class SourcesAccountEndpoint extends Endpoint {
10
10
  getCodeSourceById(codeSourceId: string): Promise<CodeSource | null>;
11
11
  getRepositories(codeSourceAccountId: string): Promise<CollectionResult<SourcesAccountRepository>>;
12
12
  getRepositoryBranches(codeSourceAccountId: string, repositoryKey: string): Promise<CollectionResult<SourcesAccountRepositoryBranch>>;
13
+ saveCodeSource(codeSource: CodeSource): Promise<CodeSource>;
13
14
  }
@@ -57,5 +57,22 @@ class SourcesAccountEndpoint extends Endpoint_1.Endpoint {
57
57
  const rawBranches = await this.requestCollection('codesourceaccounts/' + codeSourceAccountId + '/repositories/' + repositoryKey + '/branches', null, SourcesAccountRepositoryBranch_1.SourcesAccountRepositoryBranch.parse);
58
58
  return rawBranches;
59
59
  }
60
+ async saveCodeSource(codeSource) {
61
+ try {
62
+ let url = '/codesources/';
63
+ const result = await this.requestObject(url, codeSource, CodeSource_1.CodeSource.parse, 'POST');
64
+ const updatedCodeSource = result.getData();
65
+ if (updatedCodeSource === null) {
66
+ throw new Error('Unable to update code source: wrong response from API');
67
+ }
68
+ return updatedCodeSource;
69
+ }
70
+ catch (ex) {
71
+ if (this.httpClient.isDebugEnabled()) {
72
+ console.error('Failed to save code source: ', ex);
73
+ }
74
+ throw ex;
75
+ }
76
+ }
60
77
  }
61
78
  exports.SourcesAccountEndpoint = SourcesAccountEndpoint;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attlaz-client",
3
- "version": "1.9.33",
3
+ "version": "1.9.34",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",