Activates previously deployed deployment for a given stage

    CLI Example:

    .. code-block:: bash

        salt myminion boto_apigateway.activate_api_deployent restApiId stagename deploymentId
763339
def activate_api_deployment(restApiId, stageName, deploymentId,
                            region=None, key=None, keyid=None, profile=None):
    '''
    

    '''
    try:
        conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
        response = conn.update_stage(restApiId=restApiId, stageName=stageName,
                                     patchOperations=[{'op': 'replace',
                                                       'path': '/deploymentId',
                                                       'value': deploymentId}])
        return {'set': True, 'response': _convert_datetime_str(response)}
    except ClientError as e:
        return {'set': False, 'error': __utils__['boto3.get_error'](e)}
1147844
def make_auto_deployable(self, stage, swagger=None):
        
        if not swagger:
            return

        # CloudFormation does NOT redeploy the API unless it has a new deployment resource
        # that points to latest RestApi resource. Append a hash of Swagger Body location to
        # redeploy only when the API data changes. First 10 characters of hash is good enough
        # to prevent redeployment when API has not changed

        # NOTE: `str(swagger)` is for backwards compatibility. Changing it to a JSON or something will break compat
        generator = logical_id_generator.LogicalIdGenerator(self.logical_id, str(swagger))
        self.logical_id = generator.gen()
        hash = generator.get_hash(length=40)  # Get the full hash
        self.Description = "RestApi deployment id: {}".format(hash)
        stage.update_deployment_ref(self.logical_id)
644326
protected function executeDeploy($method, DeployBase $deploy)
    {
        $this->say('Deploy has initialized!');
        $deploy->beforeDeploy();
        $this->executeCommandHook($method, 'before_deploy');
        $deploy->onDeploy();
        $this->executeCommandHook($method, 'after_deploy');
        $deploy->afterDeploy();
        $this->say('Deploy has completed!');

        return $this;
    }
882043
def key_deploy(self, host, ret):
        '''
        
        '''
        if not isinstance(ret[host], dict) or self.opts.get('ssh_key_deploy'):
            target = self.targets[host]
            if target.get('passwd', False) or self.opts['ssh_passwd']:
                self._key_deploy_run(host, target, False)
            return ret
        if ret[host].get('stderr', '').count('Permission denied'):
            target = self.targets[host]
            # permission denied, attempt to auto deploy ssh key
            print(('Permission denied for host {0}, do you want to deploy '
                   'the salt-ssh key? (password required):').format(host))
            deploy = input('[Y/n] ')
            if deploy.startswith(('n', 'N')):
                return ret
            target['passwd'] = getpass.getpass(
                    'Password for {0}@{1}: '.format(target['user'], host)
                )
            return self._key_deploy_run(host, target, True)
        return ret
470423
def delete_api_stage(restApiId, stageName, region=None, key=None, keyid=None, profile=None):
    '''
    

    '''
    try:
        conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
        conn.delete_stage(restApiId=restApiId, stageName=stageName)
        return {'deleted': True}
    except ClientError as e:
        return {'deleted': False, 'error': __utils__['boto3.get_error'](e)}
129931
def create_pipeline_stage(self, pipeline_key, name, **kwargs):
		'''
		'''
		#req sanity check
		if not (pipeline_key and name):
			return requests.codes.bad_request, None

		uri = '/'.join([
						self.api_uri,
						self.pipelines_suffix,
						pipeline_key,
						self.stages_suffix])
		
		kwargs.update({'name':name})

		new_box = StreakStage(**kwargs)
		
		code, data = self._req('put', uri, new_box.to_dict(rw = True))
		
		return code, data
328917
def _list_deployment_instances(awsclient, deployment_id):
    
    client_codedeploy = awsclient.get_client('codedeploy')

    instances = []
    next_token = None

    # TODO refactor generic exhaust_function from this
    while True:
        request = {
            'deploymentId': deployment_id
        }
        if next_token:
            request['nextToken'] = next_token
        response = client_codedeploy.list_deployment_instances(**request)
        instances.extend(response['instancesList'])
        if 'nextToken' not in response:
            break
        next_token = response['nextToken']
    return instances
926069
def show_deployment(name, namespace='default', **kwargs):
    '''
    
    '''
    cfg = _setup_conn(**kwargs)
    try:
        api_instance = kubernetes.client.ExtensionsV1beta1Api()
        api_response = api_instance.read_namespaced_deployment(name, namespace)

        return api_response.to_dict()
    except (ApiException, HTTPError) as exc:
        if isinstance(exc, ApiException) and exc.status == 404:
            return None
        else:
            log.exception(
                'Exception when calling '
                'ExtensionsV1beta1Api->read_namespaced_deployment'
            )
            raise CommandExecutionError(exc)
    finally:
        _cleanup(**cfg)
1031875
def activate(self, key):
        
        url = self._base + 'user/activate'
        r = requests.get(url, params={
            'activation_key': key
        })
        r.raise_for_status()
20480
def activate_script(self):
        """"""

        # must be rethought
        # ./scripts
        # deploydir/./scripts
        self._add_scope("script")
        self.scripts = {}
        self.script_files = [
            "./scripts/script_*.txt", "~/.cloudmesh/scripts/script_*.txt"]
        self._load_scripts(self.script_files)
678850
def overwrite_stage_variables(self, ret, stage_variables):
        '''
        
        '''
        res = __salt__['boto_apigateway.overwrite_api_stage_variables'](restApiId=self.restApiId,
                                                                        stageName=self._stage_name,
                                                                        variables=stage_variables,
                                                                        **self._common_aws_args)

        if not res.get('overwrite'):
            ret['result'] = False
            ret['abort'] = True
            ret['comment'] = res.get('error')
        else:
            ret = _log_changes(ret,
                               'overwrite_stage_variables',
                               res.get('stage'))
        return ret
726280
def workflow_add_stage(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/addStage' % object_id, input_params, always_retry=always_retry, **kwargs)
961604
function DeploymentState() {
  if (!(this instanceof DeploymentState))
    return new DeploymentState();

  this.flags = Script.flags.MANDATORY_VERIFY_FLAGS;
  this.flags &= ~Script.flags.VERIFY_P2SH;
  this.lockFlags = common.lockFlags.MANDATORY_LOCKTIME_FLAGS;
  this.bip34 = false;
  this.bip91 = false;
  this.bip148 = false;
}
1269365
def dispatch_command(self, command, stage):
        

        self.api_stage = stage

        if command not in ['status', 'manage']:
            if not self.vargs.get('json', None):
                click.echo("Calling " + click.style(command, fg="green", bold=True) + " for stage " +
                           click.style(self.api_stage, bold=True) + ".." )

        # Explicitly define the app function.
        # Related: https://github.com/Miserlou/Zappa/issues/832
        if self.vargs.get('app_function', None):
            self.app_function = self.vargs['app_function']

        # Load our settings, based on api_stage.
        try:
            self.load_settings(self.vargs.get('settings_file'))
        except ValueError as e:
            if hasattr(e, 'message'):
                print("Error: {}".format(e.message))
            else:
                print(str(e))
            sys.exit(-1)
        self.callback('settings')

        # Hand it off
        if command == 'deploy': # pragma: no cover
            self.deploy(self.vargs['zip'])
        if command == 'package': # pragma: no cover
            self.package(self.vargs['output'])
        if command == 'template': # pragma: no cover
            self.template(      self.vargs['lambda_arn'],
                                self.vargs['role_arn'],
                                output=self.vargs['output'],
                                json=self.vargs['json']
                            )
        elif command == 'update': # pragma: no cover
            self.update(self.vargs['zip'], self.vargs['no_upload'])
        elif command == 'rollback': # pragma: no cover
            self.rollback(self.vargs['num_rollback'])
        elif command == 'invoke': # pragma: no cover

            if not self.vargs.get('command_rest'):
                print("Please enter the function to invoke.")
                return

            self.invoke(
                self.vargs['command_rest'],
                raw_python=self.vargs['raw'],
                no_color=self.vargs['no_color'],
            )
        elif command == 'manage': # pragma: no cover

            if not self.vargs.get('command_rest'):
                print("Please enter the management command to invoke.")
                return

            if not self.django_settings:
                print("This command is for Django projects only!")
                print("If this is a Django project, please define django_settings in your zappa_settings.")
                return

            command_tail = self.vargs.get('command_rest')
            if len(command_tail) > 1:
                command = " ".join(command_tail) # ex: zappa manage dev "shell --version"
            else:
                command = command_tail[0] # ex: zappa manage dev showmigrations admin

            self.invoke(
                command,
                command="manage",
                no_color=self.vargs['no_color'],
            )

        elif command == 'tail': # pragma: no cover
            self.tail(
                colorize=(not self.vargs['no_color']),
                http=self.vargs['http'],
                non_http=self.vargs['non_http'],
                since=self.vargs['since'],
                filter_pattern=self.vargs['filter'],
                force_colorize=self.vargs['force_color'] or None,
                keep_open=not self.vargs['disable_keep_open']
            )
        elif command == 'undeploy': # pragma: no cover
            self.undeploy(
                no_confirm=self.vargs['yes'],
                remove_logs=self.vargs['remove_logs']
            )
        elif command == 'schedule': # pragma: no cover
            self.schedule()
        elif command == 'unschedule': # pragma: no cover
            self.unschedule()
        elif command == 'status': # pragma: no cover
            self.status(return_json=self.vargs['json'])
        elif command == 'certify': # pragma: no cover
            self.certify(
                no_confirm=self.vargs['yes'],
                manual=self.vargs['manual']
            )
        elif command == 'shell': # pragma: no cover
            self.shell()
869651
def workflow_move_stage(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/moveStage' % object_id, input_params, always_retry=always_retry, **kwargs)
377659
def update_domain_base_path_mapping(self, domain_name, lambda_name, stage, base_path):
        
        api_id = self.get_api_id(lambda_name)
        if not api_id:
            print("Warning! Can't update base path mapping!")
            return
        base_path_mappings = self.apigateway_client.get_base_path_mappings(domainName=domain_name)
        found = False
        for base_path_mapping in base_path_mappings.get('items', []):
            if base_path_mapping['restApiId'] == api_id and base_path_mapping['stage'] == stage:
                found = True
                if base_path_mapping['basePath'] != base_path:
                    self.apigateway_client.update_base_path_mapping(domainName=domain_name,
                                                                    basePath=base_path_mapping['basePath'],
                                                                    patchOperations=[
                                                                        {"op" : "replace",
                                                                         "path" : "/basePath",
                                                                         "value" : '' if base_path is None else base_path}
                                                                    ])
        if not found:
            self.apigateway_client.create_base_path_mapping(
                domainName=domain_name,
                basePath='' if base_path is None else base_path,
                restApiId=api_id,
                stage=stage
            )
865522
def create_api_key(self, api_id, stage_name):
        
        response = self.apigateway_client.create_api_key(
            name='{}_{}'.format(stage_name, api_id),
            description='Api Key for {}'.format(api_id),
            enabled=True,
            stageKeys=[
                {
                    'restApiId': '{}'.format(api_id),
                    'stageName': '{}'.format(stage_name)
                },
            ]
        )
        print('Created a new x-api-key: {}'.format(response['id']))