-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #440 from sajinieKavindya/master
Support Activating and Deactivating File Inbound Endpoints via CLI and ICP
- Loading branch information
Showing
10 changed files
with
301 additions
and
6 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,64 @@ | ||
/* | ||
* Copyright (c) WSO2 LLC. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package activate | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/wso2/product-mi-tooling/cmd/credentials" | ||
impl "github.com/wso2/product-mi-tooling/cmd/impl" | ||
miUtils "github.com/wso2/product-mi-tooling/cmd/utils" | ||
) | ||
|
||
var activateInboundEndpointCmdEnvironment string | ||
|
||
const artifactInboundEndpoint = "inbound endpoint" | ||
const activateInboundEndpointCmdLiteral = "inbound-endpoint [inboundendpoint-name]" | ||
|
||
var activateInboundEndpointCmd = &cobra.Command{ | ||
Use: activateInboundEndpointCmdLiteral, | ||
Short: generateActivateCmdShortDescForArtifact(artifactInboundEndpoint), | ||
Long: generateActivateCmdLongDescForArtifact(artifactInboundEndpoint, "inboundendpoint-name"), | ||
Example: generateActivateCmdExamplesForArtifact(artifactInboundEndpoint, miUtils.GetTrimmedCmdLiteral(activateInboundEndpointCmdLiteral), "TestInboundEndpoint"), | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
handleActivateInboundEndpointCmdArguments(args) | ||
}, | ||
} | ||
|
||
func init() { | ||
ActivateCmd.AddCommand(activateInboundEndpointCmd) | ||
setEnvFlag(activateInboundEndpointCmd, &activateInboundEndpointCmdEnvironment, artifactInboundEndpoint) | ||
} | ||
|
||
func handleActivateInboundEndpointCmdArguments(args []string) { | ||
printActivateCmdVerboseLog(miUtils.GetTrimmedCmdLiteral(activateInboundEndpointCmdLiteral)) | ||
credentials.HandleMissingCredentials(activateInboundEndpointCmdEnvironment) | ||
executeActivateInboundEndpoint(args[0]) | ||
} | ||
|
||
func executeActivateInboundEndpoint(inboundEndpointName string) { | ||
resp, err := impl.ActivateInboundEndpoint(activateInboundEndpointCmdEnvironment, inboundEndpointName) | ||
if err != nil { | ||
printErrorForArtifact(artifactInboundEndpoint, inboundEndpointName, err) | ||
} else { | ||
fmt.Println(resp) | ||
} | ||
} |
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,64 @@ | ||
/* | ||
* Copyright (c) WSO2 LLC. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package deactivate | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/wso2/product-mi-tooling/cmd/credentials" | ||
"github.com/wso2/product-mi-tooling/cmd/impl" | ||
miUtils "github.com/wso2/product-mi-tooling/cmd/utils" | ||
) | ||
|
||
var deactivateInboundEndpointCmdEnvironment string | ||
|
||
const artifactInboundEndpoint = "inbound endpoint" | ||
const deactivateInboundEndpointCmdLiteral = "inbound-endpoint [inboundendpoint-name]" | ||
|
||
var deactivateInboundEndpointCmd = &cobra.Command{ | ||
Use: deactivateInboundEndpointCmdLiteral, | ||
Short: generateDeactivateCmdShortDescForArtifact(artifactInboundEndpoint), | ||
Long: generateDeactivateCmdLongDescForArtifact(artifactInboundEndpoint, "inboundendpoint-name"), | ||
Example: generateDeactivateCmdExamplesForArtifact(artifactInboundEndpoint, miUtils.GetTrimmedCmdLiteral(deactivateInboundEndpointCmdLiteral), "TestInboundEndpoint"), | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
handleDeactivateInboundEndpointCmdArguments(args) | ||
}, | ||
} | ||
|
||
func init() { | ||
DeactivateCmd.AddCommand(deactivateInboundEndpointCmd) | ||
setEnvFlag(deactivateInboundEndpointCmd, &deactivateInboundEndpointCmdEnvironment, artifactInboundEndpoint) | ||
} | ||
|
||
func handleDeactivateInboundEndpointCmdArguments(args []string) { | ||
printDeactivateCmdVerboseLog(miUtils.GetTrimmedCmdLiteral(deactivateInboundEndpointCmdLiteral)) | ||
credentials.HandleMissingCredentials(deactivateInboundEndpointCmdEnvironment) | ||
executeDeactivateInboundEndpoint(args[0]) | ||
} | ||
|
||
func executeDeactivateInboundEndpoint(inboundEndpointName string) { | ||
resp, err := impl.DeactivateInboundEndpoint(deactivateInboundEndpointCmdEnvironment, inboundEndpointName) | ||
if err != nil { | ||
printErrorForArtifact(artifactInboundEndpoint, inboundEndpointName, err) | ||
} else { | ||
fmt.Println(resp) | ||
} | ||
} |
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,38 @@ | ||
/* | ||
* Copyright (c) WSO2 LLC. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package impl | ||
|
||
import ( | ||
"github.com/wso2/product-mi-tooling/cmd/utils" | ||
) | ||
|
||
// ActivateInboundEndpoint activates an inbound endpoint deployed in the micro integrator in a given environment | ||
func ActivateInboundEndpoint(env, inboundEndpointName string) (interface{}, error) { | ||
return updateInboundEndpointServiceState(env, inboundEndpointName, "active") | ||
} | ||
|
||
// DeactivateInboundEndpoint deactivates an inbound endpoint deployed in the micro integrator in a given environment | ||
func DeactivateInboundEndpoint(env, inboundEndpointName string) (interface{}, error) { | ||
return updateInboundEndpointServiceState(env, inboundEndpointName, "inactive") | ||
} | ||
|
||
func updateInboundEndpointServiceState(env, inboundEndpointName, state string) (interface{}, error) { | ||
url := utils.GetMIManagementEndpointOfResource(utils.MiManagementInboundEndpointResource, env, utils.MainConfigFilePath) | ||
return updateArtifactState(url, inboundEndpointName, state, env) | ||
} |
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
Oops, something went wrong.