// PutOrganization will put a organization without setting an ID.
194816
func (s *Service) PutOrganization(ctx context.Context, o *influxdb.Organization) error {
	var err error
	return s.kv.Update(ctx, func(tx Tx) error {
		if pe := s.putOrganization(ctx, tx, o); pe != nil {
			err = pe
		}
		return err
	})
}
1271663
func (s *ListResourceDelegatesInput) SetOrganizationId(v string) *ListResourceDelegatesInput {
	s.OrganizationId = &v
	return s
}
571671
func (s *ListAliasesInput) SetOrganizationId(v string) *ListAliasesInput {
	s.OrganizationId = &v
	return s
}
1232415
func (c *Client) UpdateOrganization(ctx context.Context, id platform.ID, upd platform.OrganizationUpdate) (*platform.Organization, error) {
	var o *platform.Organization
	err := c.db.Update(func(tx *bolt.Tx) error {
		org, pe := c.updateOrganization(ctx, tx, id, upd)
		if pe != nil {
			return &platform.Error{
				Err: pe,
				Op:  getOp(platform.OpUpdateOrganization),
			}
		}
		o = org
		return nil
	})

	return o, err
}
1308909
func (s *DomainJoinInfo) SetOrganizationalUnitDistinguishedName(v string) *DomainJoinInfo {
	s.OrganizationalUnitDistinguishedName = &v
	return s
}
834425
func (s *DescribeOrganizationInput) SetOrganizationId(v string) *DescribeOrganizationInput {
	s.OrganizationId = &v
	return s
}
996797
func (s *ListGroupsInput) SetOrganizationId(v string) *ListGroupsInput {
	s.OrganizationId = &v
	return s
}
491331
func (s *Service) UpdateOrganization(ctx context.Context, id influxdb.ID, upd influxdb.OrganizationUpdate) (*influxdb.Organization, error) {
	var o *influxdb.Organization
	err := s.kv.Update(ctx, func(tx Tx) error {
		org, pe := s.updateOrganization(ctx, tx, id, upd)
		if pe != nil {
			return &influxdb.Error{
				Err: pe,
			}
		}
		o = org
		return nil
	})

	return o, err
}
81548
func (s *DeleteNotificationSubscriptionInput) SetOrganizationId(v string) *DeleteNotificationSubscriptionInput {
	s.OrganizationId = &v
	return s
}
635014
func (api OrganizationsAPI) AddOrganizationRegistryEntry(w http.ResponseWriter, r *http.Request) {
	globalid := mux.Vars(r)["globalid"]

	registryEntry := registry.RegistryEntry{}

	if err := json.NewDecoder(r.Body).Decode(&registryEntry); err != nil {
		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
		return
	}
	if err := registryEntry.Validate(); err != nil {
		log.Debug("Invalid registry entry: ", registryEntry)
		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
		return
	}

	mgr := registry.NewManager(r)
	err := mgr.UpsertRegistryEntry("", globalid, registryEntry)

	if err != nil {
		log.Error(err.Error())
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(http.StatusCreated)
	json.NewEncoder(w).Encode(registryEntry)
}
390114
func (s *ResetPasswordInput) SetOrganizationId(v string) *ResetPasswordInput {
	s.OrganizationId = &v
	return s
}
397526
func (s *DeleteOrganizationalUnitInput) SetOrganizationalUnitId(v string) *DeleteOrganizationalUnitInput {
	s.OrganizationalUnitId = &v
	return s
}
308372
func (s *DescribeOrganizationOutput) SetOrganizationId(v string) *DescribeOrganizationOutput {
	s.OrganizationId = &v
	return s
}
1129619
func (c *Client) PutOrganization(ctx context.Context, o *influxdb.Organization) error {
	var err error
	return c.db.Update(func(tx *bolt.Tx) error {
		if pe := c.putOrganization(ctx, tx, o); pe != nil {
			err = pe
		}
		return err
	})
}
411783
func (s *Service) CreateOrganization(ctx context.Context, o *platform.Organization) error {
	op := OpPrefix + platform.OpCreateOrganization
	if o.Name = strings.TrimSpace(o.Name); o.Name == "" {
		return platform.ErrOrgNameisEmpty
	}
	if _, err := s.FindOrganization(ctx, platform.OrganizationFilter{Name: &o.Name}); err == nil {
		return &platform.Error{
			Code: platform.EConflict,
			Op:   op,
			Msg:  fmt.Sprintf("organization with name %s already exists", o.Name),
		}
	}
	o.ID = s.IDGenerator.ID()
	err := s.PutOrganization(ctx, o)
	if err != nil {
		return &platform.Error{
			Op:  op,
			Err: err,
		}
	}
	return nil
}
988034
func (s *DescribeOrganizationalUnitInput) SetOrganizationalUnitId(v string) *DescribeOrganizationalUnitInput {
	s.OrganizationalUnitId = &v
	return s
}
106954
func (s *Service) UpdateOrganization(ctx context.Context, id platform.ID, upd platform.OrganizationUpdate) (*platform.Organization, error) {
	o, err := s.FindOrganizationByID(ctx, id)
	if err != nil {
		return nil, &platform.Error{
			Err: err,
			Op:  OpPrefix + platform.OpUpdateOrganization,
		}
	}

	if upd.Name != nil {
		o.Name = *upd.Name
	}

	s.organizationKV.Store(o.ID.String(), o)

	return o, nil
}