INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Show HaProxy frontends
def show_frontends(socket=DEFAULT_SOCKET_URL): ''' Show HaProxy frontends socket haproxy stats socket, default ``/var/run/haproxy.sock`` CLI Example: .. code-block:: bash salt '*' haproxy.show_frontends ''' ha_conn = _get_conn(socket) ha_cmd = haproxy.cmds.showFronten...
Show HaProxy Backends
def show_backends(socket=DEFAULT_SOCKET_URL): ''' Show HaProxy Backends socket haproxy stats socket, default ``/var/run/haproxy.sock`` CLI Example: .. code-block:: bash salt '*' haproxy.show_backends ''' ha_conn = _get_conn(socket) ha_cmd = haproxy.cmds.showBackends()...
.. versionadded:: 2016. 11. 0
def get_sessions(name, backend, socket=DEFAULT_SOCKET_URL): ''' .. versionadded:: 2016.11.0 Get number of current sessions on server in backend (scur) name Server name backend haproxy backend socket haproxy stats socket, default ``/var/run/haproxy.sock`` CLI Exam...
Ensure beacon is configured with the included beacon data.
def present(name, save=False, **kwargs): ''' Ensure beacon is configured with the included beacon data. Args: name (str): The name of the beacon ensure is configured. save (bool): ``True`` updates the beacons.conf. Default is ``False``. ...
Initialise netscaler connection
def _connect(**kwargs): ''' Initialise netscaler connection ''' connargs = dict() # Shamelessy ripped from the mysql module def __connarg(name, key=None, default=None): ''' Add key to connargs, only if name exists in our kwargs or as netscaler.<name> in __opts__ or __pil...
Return a service group ressource or None
def _servicegroup_get(sg_name, **connection_args): ''' Return a service group ressource or None ''' nitro = _connect(**connection_args) if nitro is None: return None sg = NSServiceGroup() sg.set_servicegroupname(sg_name) try: sg = NSServiceGroup.get(nitro, sg) except ...
Returns a list of members of a servicegroup or None
def _servicegroup_get_servers(sg_name, **connection_args): ''' Returns a list of members of a servicegroup or None ''' nitro = _connect(**connection_args) if nitro is None: return None sg = NSServiceGroup() sg.set_servicegroupname(sg_name) try: sg = NSServiceGroup.get_ser...
Returns a member of a service group or None
def _servicegroup_get_server(sg_name, s_name, s_port=None, **connection_args): ''' Returns a member of a service group or None ''' ret = None servers = _servicegroup_get_servers(sg_name, **connection_args) if servers is None: return None for server in servers: if server.get_s...
Checks if a service group exists
def servicegroup_exists(sg_name, sg_type=None, **connection_args): ''' Checks if a service group exists CLI Example: .. code-block:: bash salt '*' netscaler.servicegroup_exists 'serviceGroupName' ''' sg = _servicegroup_get(sg_name, **connection_args) if sg is None: return ...
Add a new service group If no service type is specified HTTP will be used. Most common service types: HTTP SSL and SSL_BRIDGE
def servicegroup_add(sg_name, sg_type='HTTP', **connection_args): ''' Add a new service group If no service type is specified, HTTP will be used. Most common service types: HTTP, SSL, and SSL_BRIDGE CLI Example: .. code-block:: bash salt '*' netscaler.servicegroup_add 'serviceGroupNam...
Delete a new service group
def servicegroup_delete(sg_name, **connection_args): ''' Delete a new service group CLI Example: .. code-block:: bash salt '*' netscaler.servicegroup_delete 'serviceGroupName' ''' ret = True sg = _servicegroup_get(sg_name, **connection_args) if sg is None: return False...
Check if a server: port combination is a member of a servicegroup
def servicegroup_server_exists(sg_name, s_name, s_port=None, **connection_args): ''' Check if a server:port combination is a member of a servicegroup CLI Example: .. code-block:: bash salt '*' netscaler.servicegroup_server_exists 'serviceGroupName' 'serverName' 'serverPort' ''' return...
Check if a server: port combination is in state UP in a servicegroup
def servicegroup_server_up(sg_name, s_name, s_port, **connection_args): ''' Check if a server:port combination is in state UP in a servicegroup CLI Example: .. code-block:: bash salt '*' netscaler.servicegroup_server_up 'serviceGroupName' 'serverName' 'serverPort' ''' server = _servic...
Enable a server: port member of a servicegroup
def servicegroup_server_enable(sg_name, s_name, s_port, **connection_args): ''' Enable a server:port member of a servicegroup CLI Example: .. code-block:: bash salt '*' netscaler.servicegroup_server_enable 'serviceGroupName' 'serverName' 'serverPort' ''' ret = True server = _servi...
Add a server: port member to a servicegroup
def servicegroup_server_add(sg_name, s_name, s_port, **connection_args): ''' Add a server:port member to a servicegroup CLI Example: .. code-block:: bash salt '*' netscaler.servicegroup_server_add 'serviceGroupName' 'serverName' 'serverPort' ''' # Nitro will throw an error if the serv...
Returns a service ressource or None
def _service_get(s_name, **connection_args): ''' Returns a service ressource or None ''' nitro = _connect(**connection_args) if nitro is None: return None service = NSService() service.set_name(s_name) try: service = NSService.get(nitro, service) except NSNitroError a...
Checks if a service is UP
def service_up(s_name, **connection_args): ''' Checks if a service is UP CLI Example: .. code-block:: bash salt '*' netscaler.service_up 'serviceName' ''' service = _service_get(s_name, **connection_args) return service is not None and service.get_svrstate() == 'UP'
Enable a service
def service_enable(s_name, **connection_args): ''' Enable a service CLI Example: .. code-block:: bash salt '*' netscaler.service_enable 'serviceName' ''' ret = True service = _service_get(s_name, **connection_args) if service is None: return False nitro = _connect...
Disable a service
def service_disable(s_name, s_delay=None, **connection_args): ''' Disable a service CLI Example: .. code-block:: bash salt '*' netscaler.service_disable 'serviceName' salt '*' netscaler.service_disable 'serviceName' 'delayInSeconds' ''' ret = True service = _service_get(s_...
Checks if a server exists
def server_exists(s_name, ip=None, s_state=None, **connection_args): ''' Checks if a server exists CLI Example: .. code-block:: bash salt '*' netscaler.server_exists 'serverName' ''' server = _server_get(s_name, **connection_args) if server is None: return False if ip ...
Add a server Note: The default server state is ENABLED
def server_add(s_name, s_ip, s_state=None, **connection_args): ''' Add a server Note: The default server state is ENABLED CLI Example: .. code-block:: bash salt '*' netscaler.server_add 'serverName' 'serverIpAddress' salt '*' netscaler.server_add 'serverName' 'serverIpAddress' 'se...
Delete a server
def server_delete(s_name, **connection_args): ''' Delete a server CLI Example: .. code-block:: bash salt '*' netscaler.server_delete 'serverName' ''' ret = True server = _server_get(s_name, **connection_args) if server is None: return False nitro = _connect(**conne...
Update a server s attributes
def server_update(s_name, s_ip, **connection_args): ''' Update a server's attributes CLI Example: .. code-block:: bash salt '*' netscaler.server_update 'serverName' 'serverIP' ''' altered = False cur_server = _server_get(s_name, **connection_args) if cur_server is None: ...
Check if a server is enabled globally
def server_enabled(s_name, **connection_args): ''' Check if a server is enabled globally CLI Example: .. code-block:: bash salt '*' netscaler.server_enabled 'serverName' ''' server = _server_get(s_name, **connection_args) return server is not None and server.get_state() == 'ENABLE...
Enables a server globally
def server_enable(s_name, **connection_args): ''' Enables a server globally CLI Example: .. code-block:: bash salt '*' netscaler.server_enable 'serverName' ''' ret = True server = _server_get(s_name, **connection_args) if server is None: return False if server.get_...
Checks if a vserver exists
def vserver_exists(v_name, v_ip=None, v_port=None, v_type=None, **connection_args): ''' Checks if a vserver exists CLI Example: .. code-block:: bash salt '*' netscaler.vserver_exists 'vserverName' ''' vserver = _vserver_get(v_name, **connection_args) if vserver is None: re...
Add a new lb vserver
def vserver_add(v_name, v_ip, v_port, v_type, **connection_args): ''' Add a new lb vserver CLI Example: .. code-block:: bash salt '*' netscaler.vserver_add 'vserverName' 'vserverIP' 'vserverPort' 'vserverType' salt '*' netscaler.vserver_add 'alex.patate.chaude.443' '1.2.3.4' '443' 'SS...
Delete a lb vserver
def vserver_delete(v_name, **connection_args): ''' Delete a lb vserver CLI Example: .. code-block:: bash salt '*' netscaler.vserver_delete 'vserverName' ''' ret = True vserver = _vserver_get(v_name, **connection_args) if vserver is None: return False nitro = _conne...
Bind a servicegroup to a vserver
def vserver_servicegroup_add(v_name, sg_name, **connection_args): ''' Bind a servicegroup to a vserver CLI Example: .. code-block:: bash salt '*' netscaler.vserver_servicegroup_add 'vserverName' 'serviceGroupName' ''' ret = True if vserver_servicegroup_exists(v_name, sg_name, **co...
Binds a SSL certificate to a vserver
def vserver_sslcert_add(v_name, sc_name, **connection_args): ''' Binds a SSL certificate to a vserver CLI Example: .. code-block:: bash salt '*' netscaler.vserver_sslcert_add 'vserverName' 'sslCertificateName' ''' ret = True if vserver_sslcert_exists(v_name, sc_name, **connection_...
List zones for the given profile
def list_zones(profile): ''' List zones for the given profile :param profile: The profile key :type profile: ``str`` CLI Example: .. code-block:: bash salt myminion libcloud_dns.list_zones profile1 ''' conn = _get_driver(profile=profile) return [_simple_zone(zone) for zo...
List records for the given zone_id on the given profile
def list_records(zone_id, profile, type=None): ''' List records for the given zone_id on the given profile :param zone_id: Zone to export. :type zone_id: ``str`` :param profile: The profile key :type profile: ``str`` :param type: The record type, e.g. A, NS :type type: ``str`` ...
Get zone information for the given zone_id on the given profile
def get_zone(zone_id, profile): ''' Get zone information for the given zone_id on the given profile :param zone_id: Zone to export. :type zone_id: ``str`` :param profile: The profile key :type profile: ``str`` CLI Example: .. code-block:: bash salt myminion libcloud_dns.ge...
Get record information for the given zone_id on the given profile
def get_record(zone_id, record_id, profile): ''' Get record information for the given zone_id on the given profile :param zone_id: Zone to export. :type zone_id: ``str`` :param record_id: Record to delete. :type record_id: ``str`` :param profile: The profile key :type profile: ``st...
Create a new zone.
def create_zone(domain, profile, type='master', ttl=None): ''' Create a new zone. :param domain: Zone domain name (e.g. example.com) :type domain: ``str`` :param profile: The profile key :type profile: ``str`` :param type: Zone type (master / slave). :type type: ``str`` :param ...
Update an existing zone.
def update_zone(zone_id, domain, profile, type='master', ttl=None): ''' Update an existing zone. :param zone_id: Zone ID to update. :type zone_id: ``str`` :param domain: Zone domain name (e.g. example.com) :type domain: ``str`` :param profile: The profile key :type profile: ``str``...
Create a new record.
def create_record(name, zone_id, type, data, profile): ''' Create a new record. :param name: Record name without the domain name (e.g. www). Note: If you want to create a record for a base domain name, you should specify empty string ('') for this argument...
Delete a zone.
def delete_zone(zone_id, profile): ''' Delete a zone. :param zone_id: Zone to delete. :type zone_id: ``str`` :param profile: The profile key :type profile: ``str`` :rtype: ``bool`` CLI Example: .. code-block:: bash salt myminion libcloud_dns.delete_zone google.com pro...
Delete a record.
def delete_record(zone_id, record_id, profile): ''' Delete a record. :param zone_id: Zone to delete. :type zone_id: ``str`` :param record_id: Record to delete. :type record_id: ``str`` :param profile: The profile key :type profile: ``str`` :rtype: ``bool`` CLI Example: ...
Export Zone to the BIND compatible format.
def get_bind_data(zone_id, profile): ''' Export Zone to the BIND compatible format. :param zone_id: Zone to export. :type zone_id: ``str`` :param profile: The profile key :type profile: ``str`` :return: Zone data in BIND compatible format. :rtype: ``str`` CLI Example: .. c...
Call an extended method on the driver
def extra(method, profile, **libcloud_kwargs): ''' Call an extended method on the driver :param method: Driver's method name :type method: ``str`` :param profile: The profile key :type profile: ``str`` :param libcloud_kwargs: Extra arguments for the driver's delete_container method ...
Return a string representation of a DNS record type to a libcloud RecordType ENUM.
def _string_to_record_type(string): ''' Return a string representation of a DNS record type to a libcloud RecordType ENUM. :param string: A record type, e.g. A, TXT, NS :type string: ``str`` :rtype: :class:`RecordType` ''' string = string.upper() record_type = getattr(RecordType, ...
Make a web call to IFTTT.
def _query(event=None, method='GET', args=None, header_dict=None, data=None): ''' Make a web call to IFTTT. ''' secret_key = __salt__['config.get']('ifttt.secret_key') or \ __salt__['config.get']('ifttt:secret_key') path = 'https://maker.ifttt.com/...
Trigger a configured event in IFTTT.
def trigger_event(event=None, **kwargs): ''' Trigger a configured event in IFTTT. :param event: The name of the event to trigger. :return: A dictionary with status, text, and error if result was failure. ''' res = {'result': False, 'message': 'Something went wrong'} data = {} ...
Opens the connection with the network device.
def init(opts): ''' Opens the connection with the network device. ''' NETWORK_DEVICE.update(salt.utils.napalm.get_device(opts)) DETAILS['initialized'] = True return True
Return the connection status with the remote device.
def alive(opts): ''' Return the connection status with the remote device. .. versionadded:: 2017.7.0 ''' if salt.utils.napalm.not_always_alive(opts): return True # don't force reconnection for not-always alive proxies # or regular minion is_alive_ret = call('is_alive', **{}) ...
Closes connection with the device.
def shutdown(opts): ''' Closes connection with the device. ''' try: if not NETWORK_DEVICE.get('UP', False): raise Exception('not connected!') NETWORK_DEVICE.get('DRIVER').close() except Exception as error: port = NETWORK_DEVICE.get('OPTIONAL_ARGS', {}).get('port')...
Calls a specific method from the network driver instance. Please check the readthedocs_ page for the updated list of getters.
def call(method, *args, **kwargs): ''' Calls a specific method from the network driver instance. Please check the readthedocs_ page for the updated list of getters. .. _readthedocs: http://napalm.readthedocs.org/en/latest/support/index.html#getters-support-matrix :param method: specifies the name ...
Return information about the license if the license is not correctly activated this will return None.
def info(): ''' Return information about the license, if the license is not correctly activated this will return None. CLI Example: .. code-block:: bash salt '*' license.info ''' cmd = r'cscript C:\Windows\System32\slmgr.vbs /dli' out = __salt__['cmd.run'](cmd) match = re...
Ensure the spcified api_name with the corresponding swaggerfile is deployed to the given stage_name in AWS ApiGateway.
def present(name, api_name, swagger_file, stage_name, api_key_required, lambda_integration_role, lambda_region=None, stage_variables=None, region=None, key=None, keyid=None, profile=None, lambda_funcname_format='{stage}_{api}_{resource}_{method}', authorization_type='NONE...
Helper function to retrieve stage variables from pillars/ options if the input is a string
def _get_stage_variables(stage_variables): ''' Helper function to retrieve stage variables from pillars/options, if the input is a string ''' ret = dict() if stage_variables is None: return ret if isinstance(stage_variables, six.string_types): if stage_variables in __opts__:...
Ensure the stage_name associated with the given api_name deployed by boto_apigateway s present state is removed. If the currently associated deployment to the given stage_name has no other stages associated with it the deployment will also be removed.
def absent(name, api_name, stage_name, nuke_api=False, region=None, key=None, keyid=None, profile=None): ''' Ensure the stage_name associated with the given api_name deployed by boto_apigateway's present state is removed. If the currently associated deployment to the given stage_name has no other stage...
helper function to generate a md5 hash of the swagger definition file any extra argument passed to the function is converted to a string and participates in the hash calculation
def _gen_md5_filehash(fname, *args): ''' helper function to generate a md5 hash of the swagger definition file any extra argument passed to the function is converted to a string and participates in the hash calculation ''' _hash = hashlib.md5() with salt.utils.files.fopen(fname, 'rb') as f: ...
helper function to generate pretty printed json output
def _dict_to_json_pretty(d, sort_keys=True): ''' helper function to generate pretty printed json output ''' return salt.utils.json.dumps(d, indent=4, separators=(',', ': '), sort_keys=sort_keys)
Helper function to see if given name has any of the patterns in given matches
def _name_matches(name, matches): ''' Helper function to see if given name has any of the patterns in given matches ''' for m in matches: if name.endswith(m): return True if name.lower().endswith('_' + m.lower()): return True if name.lower() == m.lower(): ...
Helper function to reduce the amount of information that will be kept in the change log for API GW related return values
def _object_reducer(o, names=('id', 'name', 'path', 'httpMethod', 'statusCode', 'Created', 'Deleted', 'Updated', 'Flushed', 'Associated', 'Disassociated')): ''' Helper function to reduce the amount of information that will be kept in the change log ...
For logging create/ update/ delete operations to AWS ApiGateway
def _log_changes(ret, changekey, changevalue): ''' For logging create/update/delete operations to AWS ApiGateway ''' cl = ret['changes'].get('new', []) cl.append({changekey: _object_reducer(changevalue)}) ret['changes']['new'] = cl return ret
helper function to update errors in the return structure
def _log_error_and_abort(ret, obj): ''' helper function to update errors in the return structure ''' ret['result'] = False ret['abort'] = True if 'error' in obj: ret['comment'] = '{0}'.format(obj.get('error')) return ret
Ensure the spcifieda usage plan with the corresponding metrics is deployed
def usage_plan_present(name, plan_name, description=None, throttle=None, quota=None, region=None, key=None, keyid=None, profile=None): ''' Ensure the spcifieda usage plan with the corresponding metrics is deployed .. versionadded:: 2017.7.0 name name of the state pl...
Ensures usage plan identified by name is no longer present
def usage_plan_absent(name, plan_name, region=None, key=None, keyid=None, profile=None): ''' Ensures usage plan identified by name is no longer present .. versionadded:: 2017.7.0 name name of the state plan_name name of the plan to remove .. code-block:: yaml usage p...
Ensures usage plan identified by name is added to provided api_stages
def usage_plan_association_present(name, plan_name, api_stages, region=None, key=None, keyid=None, profile=None): ''' Ensures usage plan identified by name is added to provided api_stages .. versionadded:: 2017.7.0 name name of the state plan_name name of the plan to use api_...
Helper function to help validate the convention established in the swagger file on how to handle response code mapping/ integration
def _validate_error_response_model(self, paths, mods): ''' Helper function to help validate the convention established in the swagger file on how to handle response code mapping/integration ''' for path, ops in paths: for opname, opobj in six.iteritems(ops): ...
Checks if the lambda function name format contains only known elements: return: True on success ValueError raised on error
def _validate_lambda_funcname_format(self): ''' Checks if the lambda function name format contains only known elements :return: True on success, ValueError raised on error ''' try: if self._lambda_funcname_format: known_kwargs = dict(stage='', ...
High level check/ validation of the input swagger file based on https:// github. com/ swagger - api/ swagger - spec/ blob/ master/ versions/ 2. 0. md
def _validate_swagger_file(self): ''' High level check/validation of the input swagger file based on https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md This is not a full schema compliance check, but rather make sure that the input file (YAML or JSON) can be...
generator to return the tuple of model and its schema to create on aws.
def models(self): ''' generator to return the tuple of model and its schema to create on aws. ''' model_dict = self._build_all_dependencies() while True: model = self._get_model_without_dependencies(model_dict) if not model: break ...
returns an iterator for the relative resource paths specified in the swagger file
def paths(self): ''' returns an iterator for the relative resource paths specified in the swagger file ''' paths = self._cfg.get('paths') if not paths: raise ValueError('Paths Object has no values, You need to define them in your swagger file') for path in pat...
this property returns the deployment label dictionary ( mainly used by stage description )
def deployment_label(self): ''' this property returns the deployment label dictionary (mainly used by stage description) ''' label = dict() label['swagger_info_object'] = self.info label['api_name'] = self.rest_api_name label['swagger_file'] = os.path.bas...
Helper function to find whether there are other stages still associated with a deployment
def _one_or_more_stages_remain(self, deploymentId): ''' Helper function to find whether there are other stages still associated with a deployment ''' stages = __salt__['boto_apigateway.describe_api_stages'](restApiId=self.restApiId, ...
Helper function to find whether there are deployments left with stages associated
def no_more_deployments_remain(self): ''' Helper function to find whether there are deployments left with stages associated ''' no_more_deployments = True deployments = __salt__['boto_apigateway.describe_api_deployments'](restApiId=self.restApiId, ...
Helper method to find the deployment id that the stage name is currently assocaited with.
def _get_current_deployment_id(self): ''' Helper method to find the deployment id that the stage name is currently assocaited with. ''' deploymentId = '' stage = __salt__['boto_apigateway.describe_api_stage'](restApiId=self.restApiId, ...
Helper method to find the deployment label that the stage_name is currently associated with.
def _get_current_deployment_label(self): ''' Helper method to find the deployment label that the stage_name is currently associated with. ''' deploymentId = self._get_current_deployment_id() deployment = __salt__['boto_apigateway.describe_api_deployment'](restApiId=self.restApiId...
Helper method to return the deployment id matching the desired deployment label for this Swagger object based on the given api_name swagger_file
def _get_desired_deployment_id(self): ''' Helper method to return the deployment id matching the desired deployment label for this Swagger object based on the given api_name, swagger_file ''' deployments = __salt__['boto_apigateway.describe_api_deployments'](restApiId=self.restAp...
overwrite the given stage_name s stage variables with the given stage_variables
def overwrite_stage_variables(self, ret, stage_variables): ''' overwrite the given stage_name's stage variables with the given stage_variables ''' res = __salt__['boto_apigateway.overwrite_api_stage_variables'](restApiId=self.restApiId, ...
Helper method to associate the stage_name to the given deploymentId and make this current
def _set_current_deployment(self, stage_desc_json, stage_variables): ''' Helper method to associate the stage_name to the given deploymentId and make this current ''' stage = __salt__['boto_apigateway.describe_api_stage'](restApiId=self.restApiId, ...
returns an Api Id that matches the given api_name and the hardcoded _Swagger. AWS_API_DESCRIPTION as the api description
def _resolve_api_id(self): ''' returns an Api Id that matches the given api_name and the hardcoded _Swagger.AWS_API_DESCRIPTION as the api description ''' apis = __salt__['boto_apigateway.describe_apis'](name=self.rest_api_name, ...
Method to delete the given stage_name. If the current deployment tied to the given stage_name has no other stages associated with it the deployment will be removed as well
def delete_stage(self, ret): ''' Method to delete the given stage_name. If the current deployment tied to the given stage_name has no other stages associated with it, the deployment will be removed as well ''' deploymentId = self._get_current_deployment_id() if d...
this method helps determine if the given stage_name is already on a deployment label matching the input api_name swagger_file.
def verify_api(self, ret): ''' this method helps determine if the given stage_name is already on a deployment label matching the input api_name, swagger_file. If yes, returns abort with comment indicating already at desired state. If not and there is previous deployment labels i...
this method tie the given stage_name to a deployment matching the given swagger_file
def publish_api(self, ret, stage_variables): ''' this method tie the given stage_name to a deployment matching the given swagger_file ''' stage_desc = dict() stage_desc['current_deployment_label'] = self.deployment_label stage_desc_json = _dict_to_json_pretty(stage_desc) ...
Helper method to clean up resources and models if we detected a change in the swagger file for a stage
def _cleanup_api(self): ''' Helper method to clean up resources and models if we detected a change in the swagger file for a stage ''' resources = __salt__['boto_apigateway.describe_api_resources'](restApiId=self.restApiId, ...
this method create the top level rest api in AWS apigateway
def deploy_api(self, ret): ''' this method create the top level rest api in AWS apigateway ''' if self.restApiId: res = self._cleanup_api() if not res.get('deleted'): ret['comment'] = 'Failed to cleanup restAreId {0}'.format(self.restApiId) ...
Method to delete a Rest Api named defined in the swagger file s Info Object s title value.
def delete_api(self, ret): ''' Method to delete a Rest Api named defined in the swagger file's Info Object's title value. ret a dictionary for returning status to Saltstack ''' exists_response = __salt__['boto_apigateway.api_exists'](name=self.rest_api_name, ...
Helper function to reference models created on aws apigw
def _aws_model_ref_from_swagger_ref(self, r): ''' Helper function to reference models created on aws apigw ''' model_name = r.split('/')[-1] return 'https://apigateway.amazonaws.com/restapis/{0}/models/{1}'.format(self.restApiId, model_name)
Helper function to map model schema to aws notation
def _update_schema_to_aws_notation(self, schema): ''' Helper function to map model schema to aws notation ''' result = {} for k, v in schema.items(): if k == '$ref': v = self._aws_model_ref_from_swagger_ref(v) if isinstance(v, dict): ...
Helper function to build the list of models the given object schema is referencing.
def _build_dependent_model_list(self, obj_schema): ''' Helper function to build the list of models the given object schema is referencing. ''' dep_models_list = [] if obj_schema: obj_schema['type'] = obj_schema.get('type', 'object') if obj_schema['type'] == '...
Helper function to build a map of model to their list of model reference dependencies
def _build_all_dependencies(self): ''' Helper function to build a map of model to their list of model reference dependencies ''' ret = {} for model, schema in six.iteritems(self._models()): dep_list = self._build_dependent_model_list(schema) ret[model] = d...
Helper function to find the next model that should be created
def _get_model_without_dependencies(self, models_dict): ''' Helper function to find the next model that should be created ''' next_model = None if not models_dict: return next_model for model, dependencies in six.iteritems(models_dict): if depende...
Method to deploy swagger file s definition objects and associated schema to AWS Apigateway as Models
def deploy_models(self, ret): ''' Method to deploy swagger file's definition objects and associated schema to AWS Apigateway as Models ret a dictionary for returning status to Saltstack ''' for model, schema in self.models(): # add in a few attributes in...
Helper method to construct lambda name based on the rule specified in doc string of boto_apigateway. api_present function
def _lambda_name(self, resourcePath, httpMethod): ''' Helper method to construct lambda name based on the rule specified in doc string of boto_apigateway.api_present function ''' lambda_name = self._lambda_funcname_format.format(stage=self._stage_name, ...
Helper Method to construct the lambda uri for use in method integration
def _lambda_uri(self, lambda_name, lambda_region): ''' Helper Method to construct the lambda uri for use in method integration ''' profile = self._common_aws_args.get('profile') region = self._common_aws_args.get('region') lambda_region = __utils__['boto3.get_region']('l...
Helper function to construct the method request params models request_templates and integration_type values needed to configure method request integration/ mappings.
def _parse_method_data(self, method_name, method_data): ''' Helper function to construct the method request params, models, request_templates and integration_type values needed to configure method request integration/mappings. ''' method_params = {} method_models = {} ...
returns the pattern specified in a response schema
def _get_pattern_for_schema(self, schema_name, httpStatus): ''' returns the pattern specified in a response schema ''' defaultPattern = '.+' if self._is_http_error_rescode(httpStatus) else '.*' model = self._models().get(schema_name) patterns = self._find_patterns(model) ...
Helper function to construct the method response params models and integration_params values needed to configure method response integration/ mappings.
def _parse_method_response(self, method_name, method_response, httpStatus): ''' Helper function to construct the method response params, models, and integration_params values needed to configure method response integration/mappings. ''' method_response_models = {} method_...
Method to create a method for the given resource path along with its associated request and response integrations.
def _deploy_method(self, ret, resource_path, method_name, method_data, api_key_required, lambda_integration_role, lambda_region, authorization_type): ''' Method to create a method for the given resource path, along with its associated request and response integrations. ...
Method to deploy resources defined in the swagger file.
def deploy_resources(self, ret, api_key_required, lambda_integration_role, lambda_region, authorization_type): ''' Method to deploy resources defined in the swagger file. ret a dictionary for returning status to Saltstack api_key_required True or False, whether ...
Create an event on the PagerDuty service
def create_event(name, details, service_key, profile): ''' Create an event on the PagerDuty service .. code-block:: yaml server-warning-message: pagerduty.create_event: - name: 'This is a server warning message' - details: 'This is a much more detailed message' ...
Execute an arbitrary query on the specified database
def run_file(name, database, query_file=None, output=None, grain=None, key=None, overwrite=True, saltenv=None, check_db_exists=True, **connection_args): ''' Execute an arbitrary query on the specified database .. versionadded:: 2017.7....
Execute an arbitrary query on the specified database
def run(name, database, query, output=None, grain=None, key=None, overwrite=True, check_db_exists=True, **connection_args): ''' Execute an arbitrary query on the specified database name Used only as an ID database The name...
Perform a query against an S3 - like API. This function requires that a secret key and the id for that key are passed in. For instance:
def query(key, keyid, method='GET', params=None, headers=None, requesturl=None, return_url=False, bucket=None, service_url=None, path='', return_bin=False, action=None, local_file=None, verify_ssl=True, full_headers=False, kms_keyid=None, location=None, role_arn=None, chunk_size=...
Works like a regular open () but writes updates into a temporary file instead of the given file and moves it over when the file is closed. The file returned behaves as if it was a regular Python
def atomic_open(filename, mode='w'): ''' Works like a regular `open()` but writes updates into a temporary file instead of the given file and moves it over when the file is closed. The file returned behaves as if it was a regular Python ''' if mode in ('r', 'rb', 'r+', 'rb+', 'a', 'ab'): ...
A salt external pillar which provides the list of nodegroups of which the minion is a member.
def ext_pillar(minion_id, pillar, pillar_name=None): ''' A salt external pillar which provides the list of nodegroups of which the minion is a member. :param minion_id: used for compound matching nodegroups :param pillar: provided by salt, but not used by nodegroups ext_pillar :param pillar_name: o...