Created
December 19, 2018 14:52
-
-
Save recursivecodes/2dd95542f48fffe32e9f8bf9c27a7cc8 to your computer and use it in GitHub Desktop.
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
package codes.recursive.service | |
import com.oracle.bmc.auth.AuthenticationDetailsProvider | |
import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider | |
import com.oracle.bmc.objectstorage.ObjectStorage | |
import com.oracle.bmc.objectstorage.ObjectStorageClient | |
import java.security.Security | |
class OciClientManager { | |
AuthenticationDetailsProvider provider | |
OciClientManager(configFilePath=System.getProperty("ociConfigPath"), profile=System.getProperty("ociProfile")) { | |
this.provider = new ConfigFileAuthenticationDetailsProvider(configFilePath, profile) | |
// per https://docs.cloud.oracle.com/iaas/Content/API/SDKDocs/javasdkconfig.htm#JavaVirtualMachineTTLforDNSNameLookups | |
Security.setProperty("networkaddress.cache.ttl" , "60") | |
} | |
ObjectStorage getObjectClient(region=System.getProperty("ociObjectStorageRegion")) { | |
ObjectStorage client = new ObjectStorageClient(this.provider) | |
client.setRegion(region) | |
return client | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment