// CreateUserResourceMapping associates a user to a resource either as a member
// or owner.
973493
func (s *Service) CreateUserResourceMapping(ctx context.Context, m *influxdb.UserResourceMapping) error {
	return s.kv.Update(ctx, func(tx Tx) error {
		return s.createUserResourceMapping(ctx, tx, m)
	})
}
513702
func unsourceMappings(p *profile.Profile) {
	for _, m := range p.Mapping {
		if m.BuildID == "" {
			if u, err := url.Parse(m.File); err == nil && u.IsAbs() {
				m.File = ""
			}
		}
	}
}
115455
func (c *FakeUserIdentityMappings) Create(userIdentityMapping *user.UserIdentityMapping) (result *user.UserIdentityMapping, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewRootCreateAction(useridentitymappingsResource, userIdentityMapping), &user.UserIdentityMapping{})
	if obj == nil {
		return nil, err
	}
	return obj.(*user.UserIdentityMapping), err
}
636443
func (s *Service) createOrgDependentMappings(ctx context.Context, tx Tx, m *influxdb.UserResourceMapping) error {
	span, ctx := tracing.StartSpanFromContext(ctx)
	defer span.Finish()

	bf := influxdb.BucketFilter{OrganizationID: &m.ResourceID}
	bs, err := s.findBuckets(ctx, tx, bf)
	if err != nil {
		return err
	}
	for _, b := range bs {
		m := &influxdb.UserResourceMapping{
			ResourceType: influxdb.BucketsResourceType,
			ResourceID:   b.ID,
			UserType:     m.UserType,
			UserID:       m.UserID,
		}
		if err := s.createUserResourceMapping(ctx, tx, m); err != nil {
			return err
		}
		// TODO(desa): add support for all other resource types.
	}

	return nil
}
405612
func eventSourceMappingPoliciesForResource(resource *resourceRef,
	template *gocf.Template,
	logger *logrus.Logger) ([]spartaIAM.PolicyStatement, error) {

	policyStatements := []spartaIAM.PolicyStatement{}

	if isResolvedResourceType(resource, template, ":dynamodb:", &gocf.DynamoDBTable{}) {
		policyStatements = append(policyStatements, CommonIAMStatements.DynamoDB...)
	} else if isResolvedResourceType(resource, template, ":kinesis:", &gocf.KinesisStream{}) {
		policyStatements = append(policyStatements, CommonIAMStatements.Kinesis...)
	} else if isResolvedResourceType(resource, template, ":sqs:", &gocf.SQSQueue{}) {
		policyStatements = append(policyStatements, CommonIAMStatements.SQS...)
	} else {
		logger.WithFields(logrus.Fields{
			"Resource": resource,
		}).Debug("No additional EventSource IAM permissions found for event type")
	}
	return policyStatements, nil
}
826845
func (s *BoshBase) CreateResourcePool(cloudPropertiesFunction func() interface{}) (*enaml.ResourcePool, error) {
	if passwordHash, err := SHA512Pass(s.DirectorPassword); err != nil {
		return nil, err
	} else {
		resourcePool := &enaml.ResourcePool{
			Name:    "vms",
			Network: "private",
		}
		resourcePool.Stemcell = enaml.Stemcell{
			URL:  s.GOAgentReleaseURL,
			SHA1: s.GOAgentSHA,
		}
		resourcePool.CloudProperties = cloudPropertiesFunction()

		resourcePool.Env = map[string]interface{}{
			"bosh": BoshPassword{
				Password: passwordHash,
			},
		}
		return resourcePool, nil
	}
}
915486
func (s *UserService) CreateUser(ctx context.Context, u *platform.User) error {
	url, err := newURL(s.Addr, usersPath)
	if err != nil {
		return err
	}

	octets, err := json.Marshal(u)
	if err != nil {
		return err
	}

	req, err := http.NewRequest("POST", url.String(), bytes.NewReader(octets))
	if err != nil {
		return err
	}

	req.Header.Set("Content-Type", "application/json")
	SetToken(s.Token, req)

	hc := newClient(url.Scheme, s.InsecureSkipVerify)

	resp, err := hc.Do(req)
	if err != nil {
		return err
	}

	// TODO(jsternberg): Should this check for a 201 explicitly?
	if err := CheckError(resp, true); err != nil {
		return err
	}

	if err := json.NewDecoder(resp.Body).Decode(u); err != nil {
		return err
	}

	return nil
}
356772
func CreateCustomResources(context Context, resources []CustomResource) error {

	var lastErr error
	for _, resource := range resources {
		if err := createCRD(context, resource); err != nil {
			lastErr = err
		}
	}

	for _, resource := range resources {
		if err := waitForCRDInit(context, resource); err != nil {
			lastErr = err
		}
	}

	return lastErr
}
744273
func (s UserResource) Create(obj interface{}, r api2go.Request) (api2go.Responder, error) {
	user, ok := obj.(model.User)
	if !ok {
		return &Response{}, api2go.NewHTTPError(errors.New("Invalid instance given"), "Invalid instance given", http.StatusBadRequest)
	}

	id := s.UserStorage.Insert(user)
	user.ID = id

	return &Response{Res: user, Code: http.StatusCreated}, nil
}
224659
func (client DefaultClient) CreateMapping(projectID, componentID, versionID string) (Mapping, error) {
	pId, err := strconv.Atoi(projectID)
	if err != nil {
		return Mapping{}, err
	}
	cId, err := strconv.Atoi(componentID)
	if err != nil {
		return Mapping{}, err
	}
	vId, err := strconv.Atoi(versionID)
	if err != nil {
		return Mapping{}, err
	}

	data, err := json.Marshal(&Mapping{ProjectID: pId, ComponentID: cId, VersionID: vId, Released: false})
	if err != nil {
		return Mapping{}, err
	}

	req, err := http.NewRequest("POST", fmt.Sprintf("%s/rest/com.deniz.jira.mapping/latest/", client.baseURL), bytes.NewBuffer(data))
	if err != nil {
		return Mapping{}, err
	}
	req.Header.Set("Content-type", "application/json")
	req.SetBasicAuth(client.username, client.password)

	response, err := client.httpClient.Do(req)
	if err != nil {
		return Mapping{}, err
	}
	defer response.Body.Close()

	data, err = ioutil.ReadAll(response.Body)
	if err != nil {
		return Mapping{}, err
	}

	if response.StatusCode != http.StatusCreated {
		logger.Printf("JIRA response: %s\n", string(data))
		return Mapping{}, fmt.Errorf("error creating mapped version.  Status code: %d.\n", response.StatusCode)
	}

	if location, err := response.Location(); err != nil {
		log.Printf("create-mapping response has no Location header.  Unable to acquire created mapping ID\n")
		return Mapping{}, nil
	} else {
		h := location.String()
		id, err := strconv.Atoi(h[strings.LastIndex(h, "/")+1:])
		if err != nil {
			log.Printf("create-mapping response Location header %s has unparseable non-integer urlPrefix/N mapping ID\n", h)
			return Mapping{}, nil
		}
		return Mapping{ID: id}, nil
	}

}
33521
func (s *UserService) CreateUser(p *CreateUserParams) (*CreateUserResponse, error) {
	resp, err := s.cs.newRequest("createUser", p.toURLValues())
	if err != nil {
		return nil, err
	}

	if resp, err = getRawValue(resp); err != nil {
		return nil, err
	}

	var r CreateUserResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
614252
func (s *UsersService) CreateUser(body User, headers, queryParams map[string]interface{}) (*http.Response, error) {
	var err error

	resp, err := s.client.doReqWithBody("POST", s.client.BaseURI+"/users", &body, headers, queryParams)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	return resp, err
}
860225
func mappingFor(user *userapi.User, identity *userapi.Identity) (*userinternal.UserIdentityMapping, error) {
	return &userinternal.UserIdentityMapping{
		ObjectMeta: metav1.ObjectMeta{
			Name:            identity.Name,
			ResourceVersion: identity.ResourceVersion,
			UID:             identity.UID,
		},
		Identity: kapi.ObjectReference{
			Name: identity.Name,
			UID:  identity.UID,
		},
		User: kapi.ObjectReference{
			Name: user.Name,
			UID:  user.UID,
		},
	}, nil
}
801178
func NewResourceService(context servicecontext.ServiceContext) service.ResourceService {
	return &resourceServiceImpl{base.NewBaseService(context)}
}
388937
func (u *UserResource) createUser(request *restful.Request, response *restful.Response) {
	usr := User{Id: request.PathParameter("user-id")}
	err := request.ReadEntity(&usr)
	if err == nil {
		u.users[usr.Id] = usr
		response.WriteHeaderAndEntity(http.StatusCreated, usr)
	} else {
		response.AddHeader("Content-Type", "text/plain")
		response.WriteErrorString(http.StatusInternalServerError, err.Error())
	}
}
171477
func (s *Service) CreateUser(ctx context.Context, u *platform.User) error {
	if _, err := s.FindUser(ctx, platform.UserFilter{Name: &u.Name}); err == nil {
		return &platform.Error{
			Code: platform.EConflict,
			Op:   OpPrefix + platform.OpCreateUser,
			Msg:  fmt.Sprintf("user with name %s already exists", u.Name),
		}
	}
	u.ID = s.IDGenerator.ID()
	s.PutUser(ctx, u)
	return nil
}
178359
func (s *storage) CreateImageStreamMapping(ctx context.Context, mapping *imageapi.ImageStreamMapping) (*metav1.Status, error) {
	obj, err := s.Create(ctx, mapping)
	if err != nil {
		return nil, err
	}
	return obj.(*metav1.Status), nil
}