
io.cloudslang.content.rft.actions.sftp.SFTPDownloadFile Maven / Gradle / Ivy
/*
* (c) Copyright 2021 Micro Focus
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License v2.0 which accompany this distribution.
*
* The Apache License is available 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 io.cloudslang.content.rft.actions.sftp;
import com.hp.oo.sdk.content.annotations.Action;
import com.hp.oo.sdk.content.annotations.Output;
import com.hp.oo.sdk.content.annotations.Param;
import com.hp.oo.sdk.content.annotations.Response;
import com.hp.oo.sdk.content.plugin.GlobalSessionObject;
import io.cloudslang.content.constants.ReturnCodes;
import io.cloudslang.content.rft.entities.sftp.SFTPCommonInputs;
import io.cloudslang.content.rft.entities.sftp.SFTPConnection;
import io.cloudslang.content.rft.entities.sftp.SFTPDownloadFileInputs;
import io.cloudslang.content.rft.services.SFTPService;
import io.cloudslang.content.rft.utils.SFTPOperation;
import io.cloudslang.content.utils.StringUtilities;
import java.util.List;
import java.util.Map;
import static com.hp.oo.sdk.content.plugin.ActionMetadata.MatchType.COMPARE_EQUAL;
import static com.hp.oo.sdk.content.plugin.ActionMetadata.ResponseType.ERROR;
import static com.hp.oo.sdk.content.plugin.ActionMetadata.ResponseType.RESOLVED;
import static io.cloudslang.content.constants.OutputNames.*;
import static io.cloudslang.content.constants.ResponseNames.FAILURE;
import static io.cloudslang.content.constants.ResponseNames.SUCCESS;
import static io.cloudslang.content.rft.utils.Constants.*;
import static io.cloudslang.content.rft.utils.Descriptions.CommonInputsDescriptions.*;
import static io.cloudslang.content.rft.utils.Descriptions.SFTPDescriptions.RETURN_RESULT_DESC;
import static io.cloudslang.content.rft.utils.Descriptions.SFTPDescriptions.*;
import static io.cloudslang.content.rft.utils.Descriptions.SFTPDownloadFileDescriptions.LOCAL_LOCATION_DESC;
import static io.cloudslang.content.rft.utils.Descriptions.SFTPDownloadFileDescriptions.REMOTE_FILE_DESC;
import static io.cloudslang.content.rft.utils.Descriptions.SFTPDownloadFileDescriptions.REMOTE_LOCATION_DESC;
import static io.cloudslang.content.rft.utils.Inputs.CommonInputs.*;
import static io.cloudslang.content.rft.utils.Inputs.SFTPInputs.*;
import static io.cloudslang.content.rft.utils.InputsValidation.verifySFTPDownloadFileInputs;
import static io.cloudslang.content.utils.OutputUtilities.getFailureResultsMap;
import static org.apache.commons.lang3.StringUtils.EMPTY;
import static org.apache.commons.lang3.StringUtils.defaultIfEmpty;
public class SFTPDownloadFile {
@Action(name = SFTP_DOWNLOAD_FILE,
outputs = {
@Output(value = RETURN_RESULT, description = RETURN_RESULT_DESC),
@Output(value = RETURN_CODE, description = RETURN_CODE_DESC),
@Output(value = EXCEPTION, description = EXCEPTION_DESC)
},
responses = {
@Response(text = SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = COMPARE_EQUAL, responseType = RESOLVED, description = SUCCESS_DESC),
@Response(text = FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, matchType = COMPARE_EQUAL, responseType = ERROR, description = FAILURE_DESC)
})
public Map execute(@Param(value = HOST, description = HOST_NAME, required = true) String host,
@Param(value = PORT, description = PORT_DESC) String port,
@Param(value = USERNAME, description = USERNAME_DESC, required = true) String username,
@Param(value = PASSWORD, description = PASSWORD_DESC, required = true, encrypted = true) String password,
@Param(value = PROXY_HOST, description = PROXY_HOST_DESC) String proxyHost,
@Param(value = PROXY_PORT, description = PROXY_PORT_DESC) String proxyPort,
@Param(value = PROXY_USERNAME, description = PROXY_USERNAME_DESC) String proxyUsername,
@Param(value = PROXY_PASSWORD, description = PROXY_PASSWORD_DESC, encrypted = true) String proxyPassword,
@Param(value = PRIVATE_KEY, description = PRIVATE_KEY_DESC) String privateKey,
@Param(value = REMOTE_FILE, description = REMOTE_FILE_DESC, required = true) String remoteFile,
@Param(value = REMOTE_LOCATION, description = REMOTE_LOCATION_DESC, required = true) String remotePath,
@Param(value = LOCAL_PATH, description = LOCAL_LOCATION_DESC, required = true) String localPath,
@Param(value = SSH_SESSIONS_DEFAULT_ID, description = GLOBAL_SESSION_DESC) GlobalSessionObject
© 2015 - 2025 Weber Informatics LLC | Privacy Policy