def create_user_context(self, access_key, secret_key, account_id=None, region_domain=None, ec2_url=None, s3_url=None, bootstrap_url=None): if not (region_domain or s3_url or ec2_url): raise ValueError( 'Can not derive service endpoints for user. ' 'Must supply either region_domain:"{0}", or ec2_url:"{1}" ' 's3_url:"{2}"'.format(region_domain, ec2_url, s3_url)) access_key = access_key or self.access_key secret_key = secret_key or self.secret_key region_domain = region_domain or self.region_domain if (not access_key and secret_key and region_domain): raise ValueError( 'Must supply access_key, secret_key and region domain to ' 'create user context') user = UserContext(aws_access_key=access_key, aws_secret_key=secret_key, region=region_domain) if ec2_url: user.ec2_url = ec2_url if s3_url: user.s3_url = s3_url if bootstrap_url: user.bootstrap_url = bootstrap_url if account_id: user.account_id = account_id return user
def create_user_context(self, access_key, secret_key, account_id=None, region_domain=None, ec2_url=None, s3_url=None, bootstrap_url=None): if not (region_domain or s3_url or ec2_url): raise ValueError('Can not derive service endpoints for user. ' 'Must supply either region_domain:"{0}", or ec2_url:"{1}" ' 's3_url:"{2}"'.format(region_domain, ec2_url, s3_url)) access_key = access_key or self.access_key secret_key = secret_key or self.secret_key region_domain = region_domain or self.region_domain if (not access_key and secret_key and region_domain): raise ValueError('Must supply access_key, secret_key and region domain to ' 'create user context') user = UserContext(aws_access_key=access_key, aws_secret_key=secret_key, region=region_domain) if ec2_url: user.ec2_url = ec2_url if s3_url: user.s3_url = s3_url if bootstrap_url: user.bootstrap_url = bootstrap_url if account_id: user.account_id = account_id return user