Skip to content

Instantly share code, notes, and snippets.

@recursivecodes
Created December 19, 2018 14:52
Show Gist options
  • Save recursivecodes/2dd95542f48fffe32e9f8bf9c27a7cc8 to your computer and use it in GitHub Desktop.
Save recursivecodes/2dd95542f48fffe32e9f8bf9c27a7cc8 to your computer and use it in GitHub Desktop.
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