-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add connect method to set destination server. #56
Merged
Merged
Changes from 16 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
8e2fd4e
change uri with serverAddress substring
661ac42
Modify serverAddress location to env
9e4defd
pre-autorest deleted and powershellcliend modified
a8d698a
Connect moved to custom
355644c
Connect modified
956afe1
Connect modified
6e0e9c9
Connect modified
eae25ad
Connect modified
1d46b74
Fix connect error in build
siadatism b7879d2
Fix uri path error
siadatism 7e77036
Fix uri path error
siadatism 9ece3c5
Cli readme file updated
ec1cf77
Reuest url modification simplified in module.cs
beb81c2
Fix code review points.
328fee8
Connect method modified for 2023-12-31 comments
207844e
Merge branch 'feature/add-connect-method-with-file' of https://github…
79d98ad
cli readme file modified for win and linux
95c6e17
Update README.md
amirhosseinmirmohammad c90f67b
Update README.md
amirhosseinmirmohammad 093379e
Update README.md
amirhosseinmirmohammad a755dee
uncomment nvm installation in pwsh
23581f8
ConfigureSwaggerOptions url changed
3d16f94
connect-method-change-address-text-modified-andcreated-new-exception-…
c71b3fe
connect-method-change-address-text-modified-andcreated-new-exception-…
1f7ede1
Modify module.cs comments format
a17520b
Some comment improvements.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,48 @@ | ||
<# | ||
.SYNOPSIS | ||
This cmdlet establishes a connection to the BSN IP Tables with the specified server address. | ||
|
||
.DESCRIPTION | ||
The Connect-BsnIPTablesCli cmdlet connects to the BSN IP Tables using the provided server address. | ||
It is a mandatory parameter, and the connection is established in the begin block. | ||
|
||
.PARAMETER ServerAddress | ||
Specifies the target server address for the connection. This is a mandatory parameter. | ||
|
||
.EXAMPLE | ||
Connect-BsnIPTablesCli -ServerAddress "http://example.com" | ||
Establishes a connection to the BSN IP Tables with the server address "http://example.com". | ||
|
||
.NOTES | ||
File Name : Connect-BsnIPTablesCli.ps1 | ||
Prerequisite : PowerShell V5 | ||
Copyright 2019 - The BSN Team | ||
#> | ||
|
||
function Connect-BsnIPTablesCli { | ||
soroshsabz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[CmdletBinding()] | ||
param( | ||
[Parameter(Mandatory)] | ||
[BSN.IpTables.V1.Category('Uri')] | ||
[System.String] | ||
# Target Server Address | ||
${ServerAddress} | ||
) | ||
|
||
begin { | ||
# Check if $ServerAddress is null | ||
if ($null -eq $ServerAddress) { | ||
Write-Error "ServerAddress is mandatory. Please provide a valid value." | ||
return | ||
} | ||
# Save the ServerAddress in a session variable | ||
$env:ServerAddress = $ServerAddress | ||
soroshsabz marked this conversation as resolved.
Show resolved
Hide resolved
soroshsabz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
process { | ||
Write-Output "Connected to: $ServerAddress" | ||
} | ||
|
||
end { | ||
} | ||
} |
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,56 @@ | ||
//The partial class Module appears to be a part of an application that utilizes AutoRest-generated code. AutoRest is a tool used for generating client libraries for accessing RESTful web services. In this context, the Module partial class is likely used to extend or modify the behavior of the AutoRest-generated classes and methods. | ||
//Here we are trying to get enviromental variable mean server address and set to requst of all urls in SendAsync method | ||
//Also we have AfterCreatePipeline,BeforeCreatePipeline and CustomInit that are called at the required places to do somethings | ||
//Pipeline Modification: The Module class contains methods (AfterCreatePipeline and BeforeCreatePipeline) that seem to be involved in the creation of an HTTP pipeline (HttpPipeline). This pipeline is likely used for handling HTTP requests and responses. | ||
//SendAsync Method: The SendAsync method is asynchronous and is involved in processing HTTP requests. It uses the GetIptabaleServerAddressAsync method to obtain a server address, modifies the request URI accordingly, and then delegates to the next step in the pipeline. | ||
|
||
using System; | ||
using System.IO; | ||
using System.Net.Http; | ||
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
|
||
namespace BSN.IpTables.V1 | ||
{ | ||
public partial class Module | ||
soroshsabz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
partial void AfterCreatePipeline( | ||
global::System.Management.Automation.InvocationInfo invocationInfo, | ||
ref BSN.IpTables.V1.Runtime.HttpPipeline pipeline | ||
) | ||
{ | ||
if (pipeline == null) | ||
throw new NullReferenceException("Pipeline is null!"); | ||
pipeline.Append(SendAsync); | ||
} | ||
|
||
partial void BeforeCreatePipeline( | ||
global::System.Management.Automation.InvocationInfo invocationInfo, | ||
ref BSN.IpTables.V1.Runtime.HttpPipeline pipeline | ||
) { } | ||
|
||
public async System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsync( | ||
System.Net.Http.HttpRequestMessage request, | ||
BSN.IpTables.V1.Runtime.IEventListener callback, | ||
BSN.IpTables.V1.Runtime.ISendAsync next | ||
) | ||
{ | ||
string serverAddress = Environment.GetEnvironmentVariable("ServerAddress").ToString(); | ||
soroshsabz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (serverAddress == null) | ||
{ | ||
Console.WriteLine("ServerAddress variable is not set."); | ||
} | ||
string requestUriString = request.RequestUri.ToString(); | ||
Uri newUri = new Uri(requestUriString); | ||
string host = newUri.Host; | ||
string finalUrl = requestUriString.Replace(host, serverAddress); | ||
request.RequestUri = new Uri(finalUrl); | ||
if (next == null) | ||
throw new NullReferenceException("Next is null!"); | ||
|
||
return await next.SendAsync(request, callback); | ||
} | ||
|
||
partial void CustomInit() { } | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resaa.net?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passive aggressive comment :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please resolve Url value