Replaces an existing deployment with a new one defined by name and
    namespace, having the specificed metadata and spec.
187805
def replace_deployment(name,
                       metadata,
                       spec,
                       source,
                       template,
                       saltenv,
                       namespace='default',
                       **kwargs):
    '''
    
    '''
    body = __create_object_body(
        kind='Deployment',
        obj_class=AppsV1beta1Deployment,
        spec_creator=__dict_to_deployment_spec,
        name=name,
        namespace=namespace,
        metadata=metadata,
        spec=spec,
        source=source,
        template=template,
        saltenv=saltenv)

    cfg = _setup_conn(**kwargs)

    try:
        api_instance = kubernetes.client.ExtensionsV1beta1Api()
        api_response = api_instance.replace_namespaced_deployment(
            name, namespace, body)

        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->replace_namespaced_deployment'
            )
            raise CommandExecutionError(exc)
    finally:
        _cleanup(**cfg)
26238
function replaceVersionsObservable(name, versions) {
  return Observable.create((observer) => {
    const package = getSrcPackageFile(name);
    let pkg = readFileSync(package, 'utf8');
    const regexs = Object.keys(versions).map(key =>
      ({ expr: new RegExp(key, 'g'), key, val: versions[key] }));
    regexs.forEach(reg => {
      pkg = pkg.replace(reg.expr, reg.val);
    });
    const outPath = getDestPackageFile(name);
    writeFile(outPath, pkg, err => {
      if (err) {
        observer.error(err);
      } else {
        observer.next(pkg);
        observer.complete();
      }
    });
  });
}
980811
public void copyDeploymentValuesToProcessDefinitions(DeploymentEntity deployment, 
      List<ProcessDefinitionEntity> processDefinitions) {
    String engineVersion = deployment.getEngineVersion();
    String tenantId = deployment.getTenantId();
    String deploymentId = deployment.getId();

    for (ProcessDefinitionEntity processDefinition : processDefinitions) {
      
      // Backwards compatibility
      if (engineVersion != null) {
        processDefinition.setEngineVersion(engineVersion);
      }

      // process definition inherits the tenant id
      if (tenantId != null) {
        processDefinition.setTenantId(tenantId); 
      }

      processDefinition.setDeploymentId(deploymentId);
    }
  }
378996
def _update_config(self, namespace):  # pylint: disable=no-self-use
        
        for key, val in namespace.items():
            setattr(config, key, val)
41066
def put(self, namespacePrefix):
        """"""
        self.reqparse.add_argument('name', type=str, required=True)
        self.reqparse.add_argument('sortOrder', type=int, required=True)
        args = self.reqparse.parse_args()

        ns = db.ConfigNamespace.find_one(ConfigNamespace.namespace_prefix == namespacePrefix)
        if not ns:
            return self.make_response('No such namespace: {}'.format(namespacePrefix), HTTP.NOT_FOUND)

        ns.name = args['name']
        ns.sort_order = args['sortOrder']
        db.session.add(ns)
        db.session.commit()

        self.dbconfig.reload_data()
        auditlog(event='configNamespace.update', actor=session['user'].username, data=args)

        return self.make_response('Namespace updated')
179036
def transform(matches, framework, namespace, static_endpoint):
    
    transformed = []
    namespace = namespace + '/' if namespace else ''

    for attribute, elements in matches:
        for element in elements:
            asset_location = get_asset_location(element, attribute)

            # string substitution
            sub_dict = {
                'static_endpoint': static_endpoint, 'namespace': namespace,
                'asset_location': asset_location
                }
            transformed_string = frameworks[framework] % sub_dict

            res = (attribute, element[attribute], transformed_string)
            transformed.append(res)

    return transformed
677389
def upsert(self, doc, namespace, timestamp, update_spec=None):
        """"""
        index, doc_type = self._index_and_mapping(namespace)
        # No need to duplicate '_id' in source document
        doc_id = u(doc.pop("_id"))
        metadata = {
            'ns': namespace,
            '_ts': timestamp
        }

        # Index the source document, using lowercase namespace as index name.
        action = {
            '_op_type': 'index',
            '_index': index,
            '_type': doc_type,
            '_id': doc_id,
            '_source': self._formatter.format_document(doc)
        }
        # Index document metadata with original namespace (mixed upper/lower).
        meta_action = {
            '_op_type': 'index',
            '_index': self.meta_index_name,
            '_type': self.meta_type,
            '_id': doc_id,
            '_source': bson.json_util.dumps(metadata)
        }

        self.index(action, meta_action, doc, update_spec)

        # Leave _id, since it's part of the original document
        doc['_id'] = doc_id
62898
def deployments(namespace='default', **kwargs):
    '''
    
    '''
    cfg = _setup_conn(**kwargs)
    try:
        api_instance = kubernetes.client.ExtensionsV1beta1Api()
        api_response = api_instance.list_namespaced_deployment(namespace)

        return [dep['metadata']['name'] for dep in api_response.to_dict().get('items')]
    except (ApiException, HTTPError) as exc:
        if isinstance(exc, ApiException) and exc.status == 404:
            return None
        else:
            log.exception(
                'Exception when calling '
                'ExtensionsV1beta1Api->list_namespaced_deployment'
            )
            raise CommandExecutionError(exc)
    finally:
        _cleanup(**cfg)
942515
def renames(old, new):
    # type: (str, str) -> None
    """"""
    # Implementation borrowed from os.renames().
    head, tail = os.path.split(new)
    if head and tail and not os.path.exists(head):
        os.makedirs(head)

    shutil.move(old, new)

    head, tail = os.path.split(old)
    if head and tail:
        try:
            os.removedirs(head)
        except OSError:
            pass
47699
function(name, config) {
            config = config || {};
            config = _.defaults(config, {
                loader: configs.resources.loader
            });
            config = _.extend(config, {
                namespace: name
            });
            Resources.namespaces[name] = config;
        }
593017
@Override
    public ReplaceDeploymentPlanBuilder andReplace(String toReplace) {
        String newContentKey = getAddedContentKey();
        return replace(newContentKey, toReplace);
    }
264916
def rename(self, new_name):
        """"""
        # Write the new object.
        self.bucket.set(new_name, self.get(), self.meta)

        # Delete the current key.
        self.delete()

        # Set the new name.
        self.name = new_name
208282
def copy(self, new_name=None):
        
        _tmp = copy.deepcopy(self)
        if not new_name:
            new_name = self.name + '_copy'
        if str(type(self)) == "<class 'pymrio.core.mriosystem.IOSystem'>":
            _tmp.meta.note('IOSystem copy {new} based on {old}'.format(
                new=new_name, old=self.meta.name))
            _tmp.meta.change_meta('name', new_name, log=False)
        else:
            _tmp.name = new_name
        return _tmp
61394
def replace_launch_config(self, scaling_group, launch_config_type,
            server_name, image, flavor, disk_config=None, metadata=None,
            personality=None, networks=None, load_balancers=None,
            key_name=None):
        
        return self._manager.replace_launch_config(scaling_group,
                launch_config_type, server_name, image, flavor,
                disk_config=disk_config, metadata=metadata,
                personality=personality, networks=networks,
                load_balancers=load_balancers, key_name=key_name)
1303580
def upsert(self, doc, namespace, timestamp):
        
        database, coll = self._db_and_collection(namespace)

        meta_collection_name = self._get_meta_collection(namespace)

        self.meta_database[meta_collection_name].replace_one(
            {self.id_field: doc["_id"], "ns": namespace},
            {self.id_field: doc["_id"], "_ts": timestamp, "ns": namespace},
            upsert=True,
        )

        self.mongo[database][coll].replace_one({"_id": doc["_id"]}, doc, upsert=True)
967997
private static Dictionary<String, Object> massageNewConfig(Dictionary<String, Object> oldProps, Dictionary<String, Object> newProps) {
        ConfigurationDictionary ret = new ConfigurationDictionary();

        if (oldProps != null) {
            for (Enumeration<String> keyItr = oldProps.keys(); keyItr.hasMoreElements();) {
                String key = keyItr.nextElement();
                if (((key.startsWith(XMLConfigConstants.CFG_CONFIG_PREFIX) && !(key.equals(XMLConfigConstants.CFG_PARENT_PID)))
                     || key.startsWith(XMLConfigConstants.CFG_SERVICE_PREFIX))) {
                    ret.put(key, oldProps.get(key));
                }

            }
        }

        if (newProps != null) {
            for (Enumeration<String> keyItr = newProps.keys(); keyItr.hasMoreElements();) {
                String key = keyItr.nextElement();
                ret.put(key, newProps.get(key));
            }
        }

        if (ret.isEmpty()) {
            ret = null;
        } else {
            // must add config.source, else things may not process properly
            ret.put(XMLConfigConstants.CFG_CONFIG_SOURCE, XMLConfigConstants.CFG_CONFIG_SOURCE_FILE);
        }
        return ret;
    }
672256
def replace_fields(meta, patterns):
    
    for pattern in patterns:
        try:
            field, regex, subst, _ = pattern.split(pattern[-1])

            # TODO: Allow numerical indices, and "+" for append
            namespace = meta
            keypath = [i.replace('\0', '.') for i in field.replace('..', '\0').split('.')]
            for key in keypath[:-1]:
                namespace = namespace[key]

            namespace[keypath[-1]] = re.sub(regex, subst, namespace[keypath[-1]])
        except (KeyError, IndexError, TypeError, ValueError) as exc:
            raise error.UserError("Bad substitution '%s' (%s)!" % (pattern, exc))

    return meta