Add a resourcegroup to a network
189475
def add_group(network_id, group,**kwargs):
    

    user_id = kwargs.get('user_id')
    try:
        net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
        net_i.check_write_permission(user_id=user_id)
    except NoResultFound:
        raise ResourceNotFoundError("Network %s not found"%(network_id))

    res_grp_i = net_i.add_group(group.name, group.description, group.status)

    hdb.add_resource_attributes(res_grp_i, group.attributes)

    db.DBSession.flush()
    if group.types is not None and len(group.types) > 0:
        res_types = []
        res_attrs = []
        res_scenarios = {}
        for typesummary in group.types:
            ra, rt, rs = template.set_resource_type(res_grp_i,
                                        typesummary.id,
                                         **kwargs)
            res_types.append(rt)
            res_attrs.extend(ra)
            res_scenarios.update(rs)#rs is a dict
        if len(res_types) > 0:
            db.DBSession.bulk_insert_mappings(ResourceType, res_types)
        if len(res_attrs) > 0:
            db.DBSession.bulk_insert_mappings(ResourceAttr, res_attrs)

            new_res_attrs = db.DBSession.query(ResourceAttr).order_by(ResourceAttr.id.desc()).limit(len(res_attrs)).all()
            all_rs = []
            for ra in new_res_attrs:
                ra_id = ra.id
                if ra.attr_id in res_scenarios:
                    rs_list = res_scenarios[ra.attr_id]
                    for rs in rs_list:
                        rs_list[rs]['resource_attr_id'] = ra_id
                        all_rs.append(rs_list[rs])

            if len(all_rs) > 0:
                db.DBSession.bulk_insert_mappings(ResourceScenario, all_rs)


    db.DBSession.refresh(res_grp_i)

    return res_grp_i
815518
def add_group_role(request, role, group, domain=None, project=None):
    """"""
    manager = keystoneclient(request, admin=True).roles
    return manager.grant(role=role, group=group, domain=domain,
                         project=project)
129498
def add_to_group(self, group_path):
        

        if self.get_group_path() != group_path:
            post_data = ADD_GROUP_TEMPLATE.format(connectware_id=self.get_connectware_id(),
                                                  group_path=group_path)
            self._conn.put('/ws/DeviceCore', post_data)

            # Invalidate cache
            self._device_json = None
1235525
function buildSubnetGroups(numZones = 0) {
  if (numZones < 2) {
    return {};
  }
  return Object.assign(
    {},
    buildRDSSubnetGroup(numZones),
    buildRedshiftSubnetGroup(numZones),
    buildElastiCacheSubnetGroup(numZones),
    buildDAXSubnetGroup(numZones),
  );
}
168492
def add(self, resource, replace=False):
        """"""
        uri = resource.uri
        if (uri in self and not replace):
            raise ResourceListDupeError(
                "Attempt to add resource already in resource_list")
        self[uri] = resource
566531
public static base_responses add(nitro_service client, systemgroup resources[]) throws Exception {
		base_responses result = null;
		if (resources != null && resources.length > 0) {
			systemgroup addresources[] = new systemgroup[resources.length];
			for (int i=0;i<resources.length;i++){
				addresources[i] = new systemgroup();
				addresources[i].groupname = resources[i].groupname;
				addresources[i].promptstring = resources[i].promptstring;
				addresources[i].timeout = resources[i].timeout;
			}
			result = add_bulk_request(client, addresources);
		}
		return result;
	}
937822
def add_ch_grp_to_interface(
        self, nexus_host, if_type, port, ch_grp):
        """"""

        if if_type != "ethernet":
            LOG.error("Unexpected interface type %(iftype)s when "
                      "adding change group", {'iftype': if_type})
            return

        starttime = time.time()

        path_snip = snipp.PATH_ALL
        path_interface = "phys-[eth" + port + "]"

        body_snip = snipp.BODY_ADD_CH_GRP % (ch_grp, ch_grp, path_interface)

        self.send_edit_string(nexus_host, path_snip, body_snip)

        self.capture_and_print_timeshot(
            starttime, "add_ch_group",
            switch=nexus_host)
9048
def cli(env, identifier):
    """"""

    mgr = SoftLayer.NetworkManager(env.client)

    secgroup = mgr.get_securitygroup(identifier)

    table = formatting.KeyValueTable(['name', 'value'])
    table.align['name'] = 'r'
    table.align['value'] = 'l'

    table.add_row(['id', secgroup['id']])
    table.add_row(['name', secgroup.get('name') or formatting.blank()])
    table.add_row(['description',
                   secgroup.get('description') or formatting.blank()])

    rule_table = formatting.Table(['id', 'remoteIp', 'remoteGroupId',
                                   'direction', 'ethertype', 'portRangeMin',
                                   'portRangeMax', 'protocol'])
    for rule in secgroup.get('rules', []):
        rg_id = rule.get('remoteGroup', {}).get('id') or formatting.blank()
        port_min = rule.get('portRangeMin')
        port_max = rule.get('portRangeMax')
        if port_min is None:
            port_min = formatting.blank()
        if port_max is None:
            port_max = formatting.blank()
        rule_table.add_row([rule['id'],
                            rule.get('remoteIp') or formatting.blank(),
                            rule.get('remoteGroupId', rg_id),
                            rule['direction'],
                            rule.get('ethertype') or formatting.blank(),
                            port_min,
                            port_max,
                            rule.get('protocol') or formatting.blank()])

    table.add_row(['rules', rule_table])

    vsi_table = formatting.Table(['id', 'hostname', 'interface', 'ipAddress'])

    for binding in secgroup.get('networkComponentBindings', []):
        try:
            vsi = binding['networkComponent']['guest']
            vsi_id = vsi['id']
            hostname = vsi['hostname']
            interface = ('PRIVATE' if binding['networkComponent']['port'] == 0
                         else 'PUBLIC')
            ip_address = (vsi['primaryBackendIpAddress']
                          if binding['networkComponent']['port'] == 0
                          else vsi['primaryIpAddress'])
        except KeyError:
            vsi_id = "N/A"
            hostname = "Not enough permission to view"
            interface = "N/A"
            ip_address = "N/A"
        vsi_table.add_row([vsi_id, hostname, interface, ip_address])

    table.add_row(['servers', vsi_table])

    env.fout(table)
193897
function(groupName, callback) {
        request.get(
            this.getResourceUrl({ path: '/groups/' + groupName, user: null }),
            function onResourceGroupResponse(err, res, body) {
                callback(err, body && body.resources, res);
            }
        );
        return this;
    }
1315189
public Observable<Page<NetworkWatcherInner>> listByResourceGroupAsync(String resourceGroupName) {
        return listByResourceGroupWithServiceResponseAsync(resourceGroupName).map(new Func1<ServiceResponse<List<NetworkWatcherInner>>, Page<NetworkWatcherInner>>() {
            @Override
            public Page<NetworkWatcherInner> call(ServiceResponse<List<NetworkWatcherInner>> response) {
                PageImpl1<NetworkWatcherInner> page = new PageImpl1<>();
                page.setItems(response.body());
                return page;
            }
        });
    }
28713
public Observable<Page<VirtualNetworkInner>> listByResourceGroupAsync(final String resourceGroupName) {
        return listByResourceGroupWithServiceResponseAsync(resourceGroupName)
            .map(new Func1<ServiceResponse<Page<VirtualNetworkInner>>, Page<VirtualNetworkInner>>() {
                @Override
                public Page<VirtualNetworkInner> call(ServiceResponse<Page<VirtualNetworkInner>> response) {
                    return response.body();
                }
            });
    }
640498
def provider_group_factory():
    """"""
    for provider in all_providers():
        p = get_notifier(provider)
        provider_name = p.name
        help = f"Options for '{provider_name}'"
        group = click.Group(name=provider_name, help=help)

        # Notify command
        notify = partial(_notify, p=p)
        group.add_command(schema_to_command(p, "notify", notify, add_message=True))

        # Resources command
        resources_callback = partial(_resources, p=p)
        resources_cmd = click.Command(
            "resources",
            callback=resources_callback,
            help="Show provider resources list",
        )
        group.add_command(resources_cmd)

        pretty_opt = click.Option(
            ["--pretty/--not-pretty"], help="Output a pretty version of the JSON"
        )

        # Add any provider resources
        for resource in p.resources:
            rsc = getattr(p, resource)
            rsrc_callback = partial(_resource, rsc)
            rsrc_command = schema_to_command(
                rsc, resource, rsrc_callback, add_message=False
            )
            rsrc_command.params.append(pretty_opt)
            group.add_command(rsrc_command)

        for name, description in CORE_COMMANDS.items():
            callback = func_factory(p, name)
            params = [pretty_opt]
            command = click.Command(
                name,
                callback=callback,
                help=description.format(provider_name),
                params=params,
            )
            group.add_command(command)

        notifiers_cli.add_command(group)
144852
public Observable<Page<DomainInner>> listByResourceGroupAsync(String resourceGroupName) {
        return listByResourceGroupWithServiceResponseAsync(resourceGroupName).map(new Func1<ServiceResponse<List<DomainInner>>, Page<DomainInner>>() {
            @Override
            public Page<DomainInner> call(ServiceResponse<List<DomainInner>> response) {
                PageImpl<DomainInner> page = new PageImpl<>();
                page.setItems(response.body());
                return page;
            }
        });
    }
928600
def add_nodes(network_id, nodes,**kwargs):
    
    start_time = datetime.datetime.now()

    names=[]        # used to check uniqueness of node name
    for n_i in nodes:
        if n_i.name in names:
            raise HydraError("Duplicate Node Name: %s"%(n_i.name))
        names.append(n_i.name)

    user_id = kwargs.get('user_id')
    try:
        net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
        net_i.check_write_permission(user_id)
    except NoResultFound:
        raise ResourceNotFoundError("Network %s not found"%(network_id))

    _add_nodes_to_database(net_i, nodes)

    net_i.project_id=net_i.project_id
    db.DBSession.flush()

    node_s =  db.DBSession.query(Node).filter(Node.network_id==network_id).all()

    #Maps temporary node_ids to real node_ids
    node_id_map = dict()

    iface_nodes = dict()
    for n_i in node_s:
        iface_nodes[n_i.name] = n_i

    for node in nodes:
        node_id_map[node.id] = iface_nodes[node.name]

    _bulk_add_resource_attrs(network_id, 'NODE', nodes, iface_nodes)

    log.info("Nodes added in %s", get_timing(start_time))
    return node_s
788633
private void addConnectionGroups(Collection<ConnectionGroup> connectionGroups) {

        // Add each connection group to the tree
        for (ConnectionGroup connectionGroup : connectionGroups) {

            // Retrieve the connection group's parent group
            APIConnectionGroup parent = retrievedGroups.get(connectionGroup.getParentIdentifier());
            if (parent != null) {

                Collection<APIConnectionGroup> children = parent.getChildConnectionGroups();
                
                // Create child collection if it does not yet exist
                if (children == null) {
                    children = new ArrayList<APIConnectionGroup>();
                    parent.setChildConnectionGroups(children);
                }

                // Add child
                APIConnectionGroup apiConnectionGroup = new APIConnectionGroup(connectionGroup);
                retrievedGroups.put(connectionGroup.getIdentifier(), apiConnectionGroup);
                children.add(apiConnectionGroup);
                
            }

            // Warn of internal consistency issues
            else
                logger.debug("Connection group \"{}\" cannot be added to the tree: parent \"{}\" does not actually exist.",
                        connectionGroup.getIdentifier(),
                        connectionGroup.getParentIdentifier());

        } // end for each connection group
        
    }
484464
function(groupName, resources, callback) {
        var url = this.getResourceUrl({ path: '/groups/' + groupName, user: null });
        request({
            method: 'PUT',
            uri: this.getSignedResourceUrl('PUT', url),
            json: resources,
            onComplete: function(err, res, body) {
                callback(err, body, res);
            }
        });

        return this;
    }
1329247
@Deprecated
    public Membership addGroupToProject(int projectId, int groupId, Collection<Role> roles) throws RedmineException {
        // "add user" and "add group" behave exactly the same way, actually. see
        // http://www.redmine.org/projects/redmine/wiki/Rest_Memberships#POST
        // http://www.redmine.org/issues/17904
        return new Membership(transport)
                .setProject(new Project(transport).setId(projectId))
                .setUserId(groupId)
                .addRoles(roles)
                .create();
    }