Search is not available for this dataset
text stringlengths 75 104k |
|---|
def get(self, key, delete_if_expired=True):
"""
Retrieve key from Cache.
:param key: key to look up in cache.
:type key: ``object``
:param delete_if_expired: remove value from cache if it is expired.
Default is True.
:type delete_if_exp... |
def insert(self, key, obj, future_expiration_minutes=15):
"""
Insert item into cache.
:param key: key to look up in cache.
:type key: ``object``
:param obj: item to store in cache.
:type obj: varies
:param future_expiration_minutes: number of minutes item is va... |
def _update_cache_stats(self, key, result):
"""
Update the cache stats.
If no cache-result is specified, we iniitialize the key.
Otherwise, we increment the correct cache-result.
Note the behavior for expired. A client can be expired and the key
still exists.
... |
def get_access_details(self, key=None):
"""Get access details in cache."""
if key in self._CACHE_STATS:
return self._CACHE_STATS['access_stats'][key]
else:
return self._CACHE_STATS['access_stats'] |
def get_stats(self):
"""Get general stats for the cache."""
expired = sum([x['expired'] for _, x in
self._CACHE_STATS['access_stats'].items()])
miss = sum([x['miss'] for _, x in
self._CACHE_STATS['access_stats'].items()])
hit = sum([x['hit'] fo... |
def get_security_group(sg_obj, flags=FLAGS.ALL, **conn):
"""
Orchestrates calls to build a Security Group in the following format:
{
"Description": ...,
"GroupName": ...,
"IpPermissions" ...,
"OwnerId" ...,
"GroupId" ...,
"IpPermissionsEgress" ...,
"V... |
def get_user(user, flags=FLAGS.ALL, **conn):
"""
Orchestrates all the calls required to fully build out an IAM User in the following format:
{
"Arn": ...,
"AccessKeys": ...,
"CreateDate": ..., # str
"InlinePolicies": ...,
"ManagedPolicies": ...,
"MFADevices"... |
def get_all_users(flags=FLAGS.ACCESS_KEYS | FLAGS.MFA_DEVICES | FLAGS.LOGIN_PROFILE | FLAGS.SIGNING_CERTIFICATES,
**conn):
"""
Returns a list of Users represented as dictionary below:
{
"Arn": ...,
"AccessKeys": ...,
"CreateDate": ..., # str
"InlinePolicie... |
def get_vpc_flow_logs(vpc, **conn):
"""Gets the VPC Flow Logs for a VPC"""
fl_result = describe_flow_logs(Filters=[{"Name": "resource-id", "Values": [vpc["id"]]}], **conn)
fl_ids = []
for fl in fl_result:
fl_ids.append(fl["FlowLogId"])
return fl_ids |
def get_classic_link(vpc, **conn):
"""Gets the Classic Link details about a VPC"""
result = {}
try:
cl_result = describe_vpc_classic_link(VpcIds=[vpc["id"]], **conn)[0]
result["Enabled"] = cl_result["ClassicLinkEnabled"]
# Check for DNS as well:
dns_result = describe_vpc_cl... |
def get_internet_gateway(vpc, **conn):
"""Gets the Internet Gateway details about a VPC"""
result = {}
ig_result = describe_internet_gateways(Filters=[{"Name": "attachment.vpc-id", "Values": [vpc["id"]]}], **conn)
if ig_result:
# Only 1 IG can be attached to a VPC:
result.update({
... |
def get_vpc_peering_connections(vpc, **conn):
"""Gets the Internet Gateway details about a VPC"""
accepter_result = describe_vpc_peering_connections(Filters=[{"Name": "accepter-vpc-info.vpc-id",
"Values": [vpc["id"]]}], **conn)
requester_resu... |
def get_subnets(vpc, **conn):
"""Gets the VPC Subnets"""
subnets = describe_subnets(Filters=[{"Name": "vpc-id", "Values": [vpc["id"]]}], **conn)
s_ids = []
for s in subnets:
s_ids.append(s["SubnetId"])
return s_ids |
def get_route_tables(vpc, **conn):
"""Gets the VPC Route Tables"""
route_tables = describe_route_tables(Filters=[{"Name": "vpc-id", "Values": [vpc["id"]]}], **conn)
rt_ids = []
for r in route_tables:
rt_ids.append(r["RouteTableId"])
return rt_ids |
def get_network_acls(vpc, **conn):
"""Gets the VPC Network ACLs"""
route_tables = describe_network_acls(Filters=[{"Name": "vpc-id", "Values": [vpc["id"]]}], **conn)
nacl_ids = []
for r in route_tables:
nacl_ids.append(r["NetworkAclId"])
return nacl_ids |
def get_base(vpc, **conn):
"""
The base will return:
- ARN
- Region
- Name
- Id
- Tags
- IsDefault
- InstanceTenancy
- CidrBlock
- CidrBlockAssociationSet
- Ipv6CidrBlockAssociationSet
- DhcpOptionsId
- Attributes
- _version
:param bucket_name:
:param... |
def get_vpc(vpc_id, flags=FLAGS.ALL, **conn):
"""
Orchestrates all the calls required to fully fetch details about a VPC:
{
"Arn": ...,
"Region": ...,
"Name": ...,
"Id": ...,
"Tags: ...,
"VpcPeeringConnections": ...,
"ClassicLink": ...,
"DhcpO... |
def get_client(service, service_type='client', **conn_args):
"""
User function to get the correct client.
Based on the GOOGLE_CLIENT_MAP dictionary, the return will be a cloud or general
client that can interact with the desired service.
:param service: GCP service to connect to. E.g. 'gce', 'iam'... |
def get_gcp_client(**kwargs):
"""Public GCP client builder."""
return _gcp_client(project=kwargs['project'], mod_name=kwargs['mod_name'],
pkg_name=kwargs.get('pkg_name', 'google.cloud'),
key_file=kwargs.get('key_file', None),
http_auth=kwargs.... |
def _gcp_client(project, mod_name, pkg_name, key_file=None, http_auth=None,
user_agent=None):
"""
Private GCP client builder.
:param project: Google Cloud project string.
:type project: ``str``
:param mod_name: Module name to load. Should be found in sys.path.
:type mod_name: ... |
def _googleauth(key_file=None, scopes=[], user_agent=None):
"""
Google http_auth helper.
If key_file is not specified, default credentials will be used.
If scopes is specified (and key_file), will be used instead of DEFAULT_SCOPES
:param key_file: path to key file to use. Default is None
:typ... |
def _build_google_client(service, api_version, http_auth):
"""
Google build client helper.
:param service: service to build client for
:type service: ``str``
:param api_version: API version to use.
:type api_version: ``str``
:param http_auth: Initialized HTTP client to use.
:type http... |
def gcp_conn(service, service_type='client', future_expiration_minutes=15):
"""
service_type: not currently used.
"""
def decorator(f):
@wraps(f)
def decorated_function(*args, **kwargs):
# Import here to avoid circular import issue
from cloudaux.gcp.auth import g... |
def gcp_stats():
"""
Collect stats
Specifically, time function calls
:returns: function response
:rtype: varies
"""
def decorator(f):
@wraps(f)
def decorated_function(*args, **kwargs):
start_time = time.time()
result = f(*args, **kwargs)
... |
def gcp_cache(future_expiration_minutes=15):
"""
Cache function output
:param future_expiration_minutes: Number of minutes in the future until item
expires. Default is 15.
:returns: function response, optionally from the cache
:rtype: varies
"""
def de... |
def iter_project(projects, key_file=None):
"""
Call decorated function for each item in project list.
Note: the function 'decorated' is expected to return a value plus a dictionary of exceptions.
If item in list is a dictionary, we look for a 'project' and 'key_file' entry, respectively.
If item i... |
def get_creds_from_kwargs(kwargs):
"""Helper to get creds out of kwargs."""
creds = {
'key_file': kwargs.pop('key_file', None),
'http_auth': kwargs.pop('http_auth', None),
'project': kwargs.get('project', None),
'user_agent': kwargs.pop('user_agent', None),
'api_version':... |
def rewrite_kwargs(conn_type, kwargs, module_name=None):
"""
Manipulate connection keywords.
Modifieds keywords based on connection type.
There is an assumption here that the client has
already been created and that these keywords are being
passed into methods for interacting with various ... |
def gce_list_aggregated(service=None, key_name='name', **kwargs):
"""General aggregated list function for the GCE service."""
resp_list = []
req = service.aggregatedList(**kwargs)
while req is not None:
resp = req.execute()
for location, item in resp['items'].items():
if key... |
def gce_list(service=None, **kwargs):
"""General list function for the GCE service."""
resp_list = []
req = service.list(**kwargs)
while req is not None:
resp = req.execute()
for item in resp.get('items', []):
resp_list.append(item)
req = service.list_next(previous_r... |
def service_list(service=None, key_name=None, **kwargs):
"""General list function for Google APIs."""
resp_list = []
req = service.list(**kwargs)
while req is not None:
resp = req.execute()
if key_name and key_name in resp:
resp_list.extend(resp[key_name])
else:
... |
def get_cache_access_details(key=None):
"""Retrieve detailed cache information."""
from cloudaux.gcp.decorators import _GCP_CACHE
return _GCP_CACHE.get_access_details(key=key) |
def get_user_agent_default(pkg_name='cloudaux'):
"""
Get default User Agent String.
Try to import pkg_name to get an accurate version number.
return: string
"""
version = '0.0.1'
try:
import pkg_resources
version = pkg_resources.get_distribution(pkg_name).version
e... |
def get_elbv2(alb, flags=FLAGS.ALL, **conn):
"""
Fully describes an ALB (ELBv2).
:param alb: Could be an ALB Name, ALB ARN, or a dictionary. Likely the return value from a previous call to describe_load_balancers. At a minimum, must contain a key titled 'LoadBalancerArn'.
:param flags: Flags describing... |
def get_event(rule, flags=FLAGS.ALL, **conn):
"""
Orchestrates all the calls required to fully build out a CloudWatch Event Rule in the following format:
{
"Arn": ...,
"Name": ...,
"Region": ...,
"Description": ...,
"State": ...,
"Rule": ...,
"Targets... |
def list_rules(client=None, **kwargs):
"""
NamePrefix='string'
"""
result = client.list_rules(**kwargs)
if not result.get("Rules"):
result.update({"Rules": []})
return result |
def list_targets_by_rule(client=None, **kwargs):
"""
Rule='string'
"""
result = client.list_targets_by_rule(**kwargs)
if not result.get("Targets"):
result.update({"Targets": []})
return result |
def get_image(image_id, flags=FLAGS.ALL, **conn):
"""
Orchestrates all the calls required to fully build out an EC2 Image (AMI, AKI, ARI)
{
"Architecture": "x86_64",
"Arn": "arn:aws:ec2:us-east-1::image/ami-11111111",
"BlockDeviceMappings": [],
"CreationDate": "2013-07-11... |
def call(self, function_expr, **kwargs):
"""
cloudaux = CloudAux(
**{'account_number': '000000000000',
'assume_role': 'role_name',
'session_name': 'testing',
'region': 'us-east-1',
'tech': 'kms',
'service_type': 'clie... |
def go(function_expr, **kwargs):
"""
CloudAux.go(
'list_aliases',
**{
'account_number': '000000000000',
'assume_role': 'role_name',
'session_name': 'cloudaux',
'region': 'us-east-1',
'tech': 'kms',
... |
def list_buckets(client=None, **kwargs):
"""
List buckets for a project.
:param client: client object to use.
:type client: Google Cloud Storage client
:returns: list of dictionary reprsentation of Bucket
:rtype: ``list`` of ``dict``
"""
buckets = client.list_buckets(**kwargs)
retu... |
def list_objects_in_bucket(**kwargs):
"""
List objects in bucket.
:param Bucket: name of bucket
:type Bucket: ``str``
:returns list of objects in bucket
:rtype: ``list``
"""
bucket = get_bucket(**kwargs)
if bucket:
return [o for o in bucket.list_blobs()]
else:
r... |
def _modify(item, func):
"""
Modifies each item.keys() string based on the func passed in.
Often used with inflection's camelize or underscore methods.
:param item: dictionary representing item to be modified
:param func: function to run on each key string
:return: dictionary where each key has... |
def modify(item, output='camelized'):
"""
Calls _modify and either passes the inflection.camelize method or the inflection.underscore method.
:param item: dictionary representing item to be modified
:param output: string 'camelized' or 'underscored'
:return:
"""
if output == 'camelized':
... |
def get_role_managed_policy_documents(role, client=None, **kwargs):
"""Retrieve the currently active policy version document for every managed policy that is attached to the role."""
policies = get_role_managed_policies(role, force_client=client)
policy_names = (policy['name'] for policy in policies)
d... |
def get_managed_policy_document(policy_arn, policy_metadata=None, client=None, **kwargs):
"""Retrieve the currently active (i.e. 'default') policy version document for a policy.
:param policy_arn:
:param policy_metadata: This is a previously fetch managed policy response from boto/cloudaux.
... |
def get_group(group_name, users=True, client=None, **kwargs):
"""Get's the IAM Group details.
:param group_name:
:param users: Optional -- will return the IAM users that the group is attached to if desired (paginated).
:param client:
:param kwargs:
:return:
"""
# First, make the initial... |
def get_group_policy_document(group_name, policy_name, client=None, **kwargs):
"""Fetches the specific IAM group inline-policy document."""
return client.get_group_policy(GroupName=group_name, PolicyName=policy_name, **kwargs)['PolicyDocument'] |
def _get_base(server_certificate, **conn):
"""Fetch the base IAM Server Certificate."""
server_certificate['_version'] = 1
# Get the initial cert details:
cert_details = get_server_certificate_api(server_certificate['ServerCertificateName'], **conn)
if cert_details:
server_certificate.upda... |
def get_server_certificate(server_certificate, flags=FLAGS.BASE, **conn):
"""
Orchestrates all the calls required to fully build out an IAM User in the following format:
{
"Arn": ...,
"ServerCertificateName": ...,
"Path": ...,
"ServerCertificateId": ...,
"UploadDate"... |
def get_item(item, **kwargs):
"""
API versioning for each OpenStack service is independent. Generically capture
the public members (non-routine and non-private) of the OpenStack SDK objects.
Note the lack of the modify_output decorator. Preserving the field naming allows
us to reconstruct o... |
def sub_list(l):
"""
Recursively walk a data-structure sorting any lists along the way.
Any unknown types get mapped to string representation
:param l: list
:return: sorted list, where any child lists are also sorted.
"""
r = []
for i in l:
if type(i) in prims:
r.ap... |
def sub_dict(d):
"""
Recursively walk a data-structure sorting any lists along the way.
Any unknown types get mapped to string representation
:param d: dict
:return: dict where any lists, even those buried deep in the structure, have been sorted.
"""
r = {}
for k in d:
if type(d... |
def boto3_cached_conn(service, service_type='client', future_expiration_minutes=15, account_number=None,
assume_role=None, session_name='cloudaux', region='us-east-1', return_credentials=False,
external_id=None, arn_partition='aws'):
"""
Used to obtain a boto3 client ... |
def sts_conn(service, service_type='client', future_expiration_minutes=15):
"""
This will wrap all calls with an STS AssumeRole if the required parameters are sent over.
Namely, it requires the following in the kwargs:
- Service Type (Required)
- Account Number (Required for Assume Role)
- IAM R... |
def list_bucket_analytics_configurations(client=None, **kwargs):
"""
Bucket='string'
"""
result = client.list_bucket_analytics_configurations(**kwargs)
if not result.get("AnalyticsConfigurationList"):
result.update({"AnalyticsConfigurationList": []})
return result |
def list_bucket_metrics_configurations(client=None, **kwargs):
"""
Bucket='string'
"""
result = client.list_bucket_metrics_configurations(**kwargs)
if not result.get("MetricsConfigurationList"):
result.update({"MetricsConfigurationList": []})
return result |
def list_bucket_inventory_configurations(client=None, **kwargs):
"""
Bucket='string'
"""
result = client.list_bucket_inventory_configurations(**kwargs)
if not result.get("InventoryConfigurationList"):
result.update({"InventoryConfigurationList": []})
return result |
def get_queue(queue, flags=FLAGS.ALL, **conn):
"""
Orchestrates all the calls required to fully fetch details about an SQS Queue:
{
"Arn": ...,
"Region": ...,
"Name": ...,
"Url": ...,
"Attributes": ...,
"Tags": ...,
"DeadLetterSourceQueues": ...,
... |
def get_bucket(bucket_name, include_created=None, flags=FLAGS.ALL ^ FLAGS.CREATED_DATE, **conn):
"""
Orchestrates all the calls required to fully build out an S3 bucket in the following format:
{
"Arn": ...,
"Name": ...,
"Region": ...,
"Owner": ...,
"Grants": ...... |
def _get_base(role, **conn):
"""
Determine whether the boto get_role call needs to be made or if we already have all that data
in the role object.
:param role: dict containing (at the very least) role_name and/or arn.
:param conn: dict containing enough information to make a connection to the desire... |
def get_role(role, flags=FLAGS.ALL, **conn):
"""
Orchestrates all the calls required to fully build out an IAM Role in the following format:
{
"Arn": ...,
"AssumeRolePolicyDocument": ...,
"CreateDate": ..., # str
"InlinePolicies": ...,
"InstanceProfiles": ...,
... |
def get_all_roles(**conn):
"""
Returns a List of Roles represented as the dictionary below:
{
"Arn": ...,
"AssumeRolePolicyDocument": ...,
"CreateDate": ..., # str
"InlinePolicies": ...,
"InstanceProfiles": ...,
"ManagedPolicies": ...,
"Path": ...,
... |
def _get_policy(lambda_function, **conn):
"""Get LambdaFunction Policies. (there can be many of these!)
Lambda Function Policies are overly complicated. They can be attached to a label,
a version, and there is also a default policy.
This method attempts to gather all three types.
AW... |
def get_lambda_function(lambda_function, flags=FLAGS.ALL, **conn):
"""Fully describes a lambda function.
Args:
lambda_function: Name, ARN, or dictionary of lambda function. If dictionary, should likely be the return value from list_functions. At a minimum, must contain a key titled 'FunctionName'.
... |
def list_items(conn=None, **kwargs):
"""
:rtype: ``list``
"""
return [x for x in getattr( getattr( conn, kwargs.pop('service') ),
kwargs.pop('generator'))(**kwargs)] |
def get_serviceaccount(client=None, **kwargs):
"""
service_account='string'
"""
service_account=kwargs.pop('service_account')
resp = client.projects().serviceAccounts().get(
name=service_account).execute()
return resp |
def get_serviceaccount_keys(client=None, **kwargs):
"""
service_account='string'
"""
service_account=kwargs.pop('service_account')
kwargs['name'] = service_account
return service_list(client.projects().serviceAccounts().keys(),
key_name='keys', **kwargs) |
def get_iam_policy(client=None, **kwargs):
"""
service_account='string'
"""
service_account=kwargs.pop('service_account')
resp = client.projects().serviceAccounts().getIamPolicy(
resource=service_account).execute()
# TODO(supertom): err handling, check if 'bindings' is correct
if 'bi... |
def get_vault(vault_obj, flags=FLAGS.ALL, **conn):
"""
Orchestrates calls to build a Glacier Vault in the following format:
{
"VaultARN": ...,
"VaultName": ...,
"CreationDate" ...,
"LastInventoryDate" ...,
"NumberOfArchives" ...,
"SizeInBytes" ...,
"P... |
def get_rules(security_group, **kwargs):
""" format the rule fields to match AWS to support auditor reuse,
will need to remap back if we want to orchestrate from our stored items """
rules = security_group.pop('security_group_rules',[])
for rule in rules:
rule['ip_protocol'] = rule.pop('prot... |
def get_security_group(security_group, flags=FLAGS.ALL, **kwargs):
result = registry.build_out(flags, start_with=security_group, pass_datastructure=True, **kwargs)
""" just store the AWS formatted rules """
result.pop('security_group_rules', [])
return result |
def _conn_from_arn(arn):
"""
Extracts the account number from an ARN.
:param arn: Amazon ARN containing account number.
:return: dictionary with a single account_number key that can be merged with an existing
connection dictionary containing fields such as assume_role, session_name, region.
"""
... |
def _get_name_from_structure(item, default):
"""
Given a possibly sparsely populated item dictionary, try to retrieve the item name.
First try the default field. If that doesn't exist, try to parse the from the ARN.
:param item: dict containing (at the very least) item_name and/or arn
:return: item... |
def describe_load_balancers(arns=None, names=None, client=None):
"""
Permission: elasticloadbalancing:DescribeLoadBalancers
"""
kwargs = dict()
if arns:
kwargs.update(dict(LoadBalancerArns=arns))
if names:
kwargs.update(dict(Names=names))
return client.describe_load_balancers... |
def describe_listeners(load_balancer_arn=None, listener_arns=None, client=None):
"""
Permission: elasticloadbalancing:DescribeListeners
"""
kwargs = dict()
if load_balancer_arn:
kwargs.update(dict(LoadBalancerArn=load_balancer_arn))
if listener_arns:
kwargs.update(dict(ListenerAr... |
def describe_rules(listener_arn=None, rule_arns=None, client=None):
"""
Permission: elasticloadbalancing:DescribeRules
"""
kwargs = dict()
if listener_arn:
kwargs.update(dict(ListenerArn=listener_arn))
if rule_arns:
kwargs.update(dict(RuleArns=rule_arns))
return client.descri... |
def describe_target_groups(load_balancer_arn=None, target_group_arns=None, names=None, client=None):
"""
Permission: elasticloadbalancing:DescribeTargetGroups
"""
kwargs = dict()
if load_balancer_arn:
kwargs.update(LoadBalancerArn=load_balancer_arn)
if target_group_arns:
kwargs.u... |
def describe_target_health(target_group_arn, targets=None, client=None):
"""
Permission: elasticloadbalancing:DescribeTargetHealth
"""
kwargs = dict(TargetGroupArn=target_group_arn)
if targets:
kwargs.update(Targets=targets)
return client.describe_target_health(**kwargs)['TargetHealthDes... |
def get_inline_policies(group, **conn):
"""Get the inline policies for the group."""
policy_list = list_group_policies(group['GroupName'])
policy_documents = {}
for policy in policy_list:
policy_documents[policy] = get_group_policy_document(group['GroupName'], policy, **conn)
return polic... |
def get_managed_policies(group, **conn):
"""Get a list of the managed policy names that are attached to the group."""
managed_policies = list_attached_group_managed_policies(group['GroupName'], **conn)
managed_policy_names = []
for policy in managed_policies:
managed_policy_names.append(policy... |
def get_users(group, **conn):
"""Gets a list of the usernames that are a part of this group."""
group_details = get_group_api(group['GroupName'], **conn)
user_list = []
for user in group_details.get('Users', []):
user_list.append(user['UserName'])
return user_list |
def _get_base(group, **conn):
"""Fetch the base IAM Group."""
group['_version'] = 1
# Get the initial group details (only needed if we didn't grab the users):
group.update(get_group_api(group['GroupName'], users=False, **conn)['Group'])
# Cast CreateDate from a datetime to something JSON serializa... |
def get_group(group, flags=FLAGS.BASE | FLAGS.INLINE_POLICIES | FLAGS.MANAGED_POLICIES, **conn):
"""
Orchestrates all the calls required to fully build out an IAM Group in the following format:
{
"Arn": ...,
"GroupName": ...,
"Path": ...,
"GroupId": ...,
"CreateDate"... |
def get_base(managed_policy, **conn):
"""Fetch the base Managed Policy.
This includes the base policy and the latest version document.
:param managed_policy:
:param conn:
:return:
"""
managed_policy['_version'] = 1
arn = _get_name_from_structure(managed_policy, 'Arn')
policy = get... |
def get_managed_policy(managed_policy, flags=FLAGS.ALL, **conn):
"""
Orchestrates all of the calls required to fully build out an IAM Managed Policy in the following format:
{
"Arn": "...",
"PolicyName": "...",
"PolicyId": "...",
"Path": "...",
"DefaultVersionId": ".... |
def _name(named):
"""Get the name out of an object. This varies based on the type of the input:
* the "name" of a string is itself
* the "name" of None is itself
* the "name" of an object with a property named name is that property -
as long as it's a string
* otherwise, we rai... |
def get_version(self):
'''obtain the version or just 2.2.x if < 2.3.x
Raises:
FailedRequestError: If the request fails.
'''
if self._version:
return self._version
url = "{}/about/version.xml".format(self.service_url)
resp = self.http_request(url)
... |
def get_short_version(self):
'''obtain the shory geoserver version
'''
gs_version = self.get_version()
match = re.compile(r'[^\d.]+')
return match.sub('', gs_version).strip('.') |
def delete(self, config_object, purge=None, recurse=False):
"""
send a delete request
XXX [more here]
"""
rest_url = config_object.href
params = []
# purge deletes the SLD from disk when a style is deleted
if purge:
params.append("purge=" + st... |
def save(self, obj, content_type="application/xml"):
"""
saves an object to the REST service
gets the object's REST location and the data from the object,
then POSTS the request.
"""
rest_url = obj.href
data = obj.message()
headers = {
"Conten... |
def get_stores(self, names=None, workspaces=None):
'''
Returns a list of stores in the catalog. If workspaces is specified will only return stores in those workspaces.
If names is specified, will only return stores that match.
names can either be a comma delimited string or an arra... |
def get_store(self, name, workspace=None):
'''
Returns a single store object.
Will return None if no store is found.
Will raise an error if more than one store with the same name is found.
'''
stores = self.get_stores(workspaces=workspace, names=name)
retur... |
def create_coveragestore(self, name, workspace=None, path=None, type='GeoTIFF',
create_layer=True, layer_name=None, source_name=None, upload_data=False, contet_type="image/tiff"):
"""
Create a coveragestore for locally hosted rasters.
If create_layer is set to true, ... |
def add_granule(self, data, store, workspace=None):
'''Harvest/add a granule into an existing imagemosaic'''
ext = os.path.splitext(data)[-1]
if ext == ".zip":
type = "file.imagemosaic"
upload_data = open(data, 'rb')
headers = {
"Content-type":... |
def delete_granule(self, coverage, store, granule_id, workspace=None):
'''Deletes a granule of an existing imagemosaic'''
params = dict()
workspace_name = workspace
if isinstance(store, basestring):
store_name = store
else:
store_name = store.name
... |
def list_granules(self, coverage, store, workspace=None, filter=None, limit=None, offset=None):
'''List granules of an imagemosaic'''
params = dict()
if filter is not None:
params['filter'] = filter
if limit is not None:
params['limit'] = limit
if offset ... |
def mosaic_coverages(self, store):
'''Returns all coverages in a coverage store'''
params = dict()
url = build_url(
self.service_url,
[
"workspaces",
store.workspace.name,
"coveragestores",
store.name,
... |
def publish_featuretype(self, name, store, native_crs, srs=None, jdbc_virtual_table=None, native_name=None):
'''Publish a featuretype from data in an existing store'''
# @todo native_srs doesn't seem to get detected, even when in the DB
# metadata (at least for postgis in geometry_columns) and t... |
def get_resources(self, names=None, stores=None, workspaces=None):
'''
Resources include feature stores, coverage stores and WMS stores, however does not include layer groups.
names, stores and workspaces can be provided as a comma delimited strings or as arrays, and are used for filtering.
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.