-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Binali Rustamov
committed
Dec 21, 2019
1 parent
d05edc5
commit 70f94b7
Showing
15 changed files
with
127 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Dockerfile | ||
**/*/ | ||
!PortainerClient/bin/Release/netcoreapp3.1/publish/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM mcr.microsoft.com/dotnet/core/runtime:2.2.5-bionic | ||
|
||
WORKDIR /app | ||
|
||
COPY Rustamov.PortainerClient/bin/Release/netcoreapp2.2/publish/ . | ||
|
||
RUN echo '#!/bin/bash\n dotnet /app/Rustamov.PortainerClient.dll "$@"' > /usr/bin/portainerctl && \ | ||
chmod +x /usr/bin/portainerctl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Collections.Generic; | ||
using RestSharp; | ||
|
||
namespace PortainerClient.Api | ||
{ | ||
public static class BaseApiHelpers | ||
{ | ||
public static void AddParameters(this RestRequest request, | ||
IEnumerable<(string paramName, object paramValue)> parameters) | ||
{ | ||
foreach (var (paramName, paramValue) in parameters) request.AddParameter(paramName, paramValue); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace PortainerClient.Api.Model | ||
{ | ||
public class ApiError | ||
{ | ||
public string message { get; set; } | ||
public string details { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace PortainerClient.Api.Model | ||
{ | ||
public class StackFileInspect | ||
{ | ||
public string StackFileContent { get; set; } | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using PortainerClient.Api; | ||
using PortainerClient.Api.Model; | ||
|
||
namespace PortainerClient.Command.Stack | ||
{ | ||
public class StacksApiService : BaseApiService | ||
{ | ||
public IEnumerable<StackInfo> GetStacks() => Get<List<StackInfo>>("stacks"); | ||
|
||
public string GetStackFile(int stackId) => Get<StackFileInspect>($"stacks/{stackId}/file").StackFileContent; | ||
|
||
public StackInfo GetStackInfo(in int stackId) => Get<StackInfo>($"stacks/{stackId}"); | ||
|
||
public void RemoveStack(int stackId) => Delete($"stacks/{stackId}"); | ||
|
||
public object DeployStack(in int endpointId, string name, string swarmID, string stackFilePath, string env) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
using IO.Swagger.Api; | ||
using McMaster.Extensions.CommandLineUtils; | ||
using PortainerClient.Helpers; | ||
|
||
namespace PortainerClient.Command.Stack | ||
{ | ||
[Command(Name = "getfile", Description = "Get compose file of stack")] | ||
public class StackGetFileCmd : BaseApiCommand<StacksApi> | ||
public class StackGetFileCmd : BaseApiCommand<StacksApiService> | ||
{ | ||
[Argument(0, "stackId", "Stack instance identifier")] | ||
[Required] | ||
public int StackId { get; set; } | ||
|
||
public override void Do(CommandLineApplication app, IConsole console) | ||
{ | ||
var data = ApiClient.StackFileInspect(StackId); | ||
console.Write(data.StackFileContent); | ||
var data = ApiClient.GetStackFile(StackId); | ||
console.Write(data); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using IO.Swagger.Api; | ||
using McMaster.Extensions.CommandLineUtils; | ||
using YamlDotNet.Serialization; | ||
|
||
namespace PortainerClient.Command.Stack | ||
{ | ||
[Command("inspect", Description = "Show information about stack")] | ||
public class StackInspectCmd : BaseApiCommand<StacksApi> | ||
public class StackInspectCmd : BaseApiCommand<StacksApiService> | ||
{ | ||
[Argument(0, "stackId", "Stack identifier")] | ||
[Required] | ||
public int StackId { get; set; } | ||
|
||
public override void Do(CommandLineApplication app, IConsole console) | ||
{ | ||
var stackInfo = ApiClient.StackInspect(StackId); | ||
var stackInfo = ApiClient.GetStackInfo(StackId); | ||
console.WriteLine(new Serializer().Serialize(stackInfo)); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters