|
1 | | -using Octopus.Client; |
| 1 | +using System.IO; |
| 2 | +using System.Runtime.InteropServices.ComTypes; |
| 3 | +using Octopus.Client; |
| 4 | +using Octopus.Client.Model; |
2 | 5 | using ScriptCs.Contracts; |
3 | 6 |
|
4 | 7 | namespace ScriptCs.OctopusClient |
5 | 8 | { |
6 | 9 | public class OctopusClientPack : IScriptPackContext |
7 | 10 | { |
8 | | - public OctopusRepository GetRepository(string hostUrl, string apiKey) |
| 11 | + private IOctopusClient _client; |
| 12 | + |
| 13 | + public OctopusRepository Server(string hostUrl, string apiKey) |
9 | 14 | { |
10 | 15 | var endpoint = new OctopusServerEndpoint(hostUrl, apiKey); |
11 | | - |
12 | | - return new OctopusRepository(endpoint); |
| 16 | + var repository = new OctopusRepository(endpoint); |
| 17 | + _client = repository.Client; |
| 18 | + |
| 19 | + return repository; |
| 20 | + } |
| 21 | + |
| 22 | + public RootResource GetRootDocument() |
| 23 | + { |
| 24 | + return _client.RootDocument; |
| 25 | + } |
| 26 | + |
| 27 | + public ResourceCollection<T> List<T>(string path, object pathParameters = null) |
| 28 | + { |
| 29 | + return _client.List<T>(path, pathParameters); |
| 30 | + } |
| 31 | + |
| 32 | + public T Get<T>(string path, object pathParameters = null) |
| 33 | + { |
| 34 | + return _client.Get<T>(path, pathParameters); |
| 35 | + } |
| 36 | + |
| 37 | + public Stream GetContent(string path) |
| 38 | + { |
| 39 | + return _client.GetContent(path); |
| 40 | + } |
| 41 | + |
| 42 | + public T Create<T>(string path, T resource) |
| 43 | + { |
| 44 | + return _client.Create(path, resource); |
| 45 | + } |
| 46 | + |
| 47 | + public void Post(string path) |
| 48 | + { |
| 49 | + _client.Post(path); |
| 50 | + } |
| 51 | + public void Post<T>(string path, T resource) |
| 52 | + { |
| 53 | + _client.Post(path, resource); |
| 54 | + } |
| 55 | + |
| 56 | + public void Put<T>(string path, T resource) |
| 57 | + { |
| 58 | + _client.Put(path, resource); |
| 59 | + } |
| 60 | + |
| 61 | + public void PutContent(string path, Stream content) |
| 62 | + { |
| 63 | + _client.PutContent(path, content); |
| 64 | + } |
| 65 | + |
| 66 | + public T Update<T>(string path, T resource) |
| 67 | + { |
| 68 | + return _client.Update(path, resource); |
| 69 | + } |
| 70 | + |
| 71 | + public TaskResource Delete(string path) |
| 72 | + { |
| 73 | + return _client.Delete(path); |
13 | 74 | } |
14 | 75 | } |
15 | 76 | } |
0 commit comments