// DefaultOrganizationID returns the ID of the default organization
544874
func (s *OrganizationsStore) DefaultOrganization(ctx context.Context) (*chronograf.Organization, error) {
	var org chronograf.Organization
	if err := s.client.db.View(func(tx *bolt.Tx) error {
		v := tx.Bucket(OrganizationsBucket).Get(DefaultOrganizationID)
		return internal.UnmarshalOrganization(v, &org)
	}); err != nil {
		return nil, err
	}

	return &org, nil
}
1366809
func (m *Membership) GetOrganizationURL() string {
	if m == nil || m.OrganizationURL == nil {
		return ""
	}
	return *m.OrganizationURL
}
401877
func (s *Service) OrganizationID(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()

	id := httprouter.GetParamFromContext(ctx, "oid")

	org, err := s.Store.Organizations(ctx).Get(ctx, chronograf.OrganizationQuery{ID: &id})
	if err != nil {
		Error(w, http.StatusBadRequest, err.Error(), s.Logger)
		return
	}

	res := newOrganizationResponse(org)
	encodeJSON(w, http.StatusOK, res, s.Logger)
}
959406
func (s *Service) FindOrganizationByID(ctx context.Context, id platform.ID) (*platform.Organization, error) {
	o, pe := s.loadOrganization(id)
	if pe != nil {
		return nil, &platform.Error{
			Op:  OpPrefix + platform.OpFindOrganizationByID,
			Err: pe,
		}
	}
	return o, nil
}
482212
func (s *DescribeUserInput) SetOrganizationId(v string) *DescribeUserInput {
	s.OrganizationId = &v
	return s
}
738915
func (s *ListUsersInput) SetOrganizationId(v string) *ListUsersInput {
	s.OrganizationId = &v
	return s
}
213646
func (org *Organization) CreateOrganization(newOrg NewOrganization) error {
	var (
		r orgCreationResponse
		b bytes.Buffer
	)
	err := json.NewEncoder(&b).Encode(newOrg)
	if err != nil {
		return err
	}
	err = org.PPE.post(fmt.Sprintf("/orgs/%s/orgs", org.PrimaryDomain), &b, &r)
	if err != nil {
		return err
	}
	if len(r.FailResults) >= 1 {
		return errors.New(r.FailResults[0].Result.Message)
	}
	return nil
}
571671
func (s *ListAliasesInput) SetOrganizationId(v string) *ListAliasesInput {
	s.OrganizationId = &v
	return s
}
275087
func (m *Manager) RemoveOrganization(globalID string, organization string) error {
	qry := bson.M{"globalid": globalID}
	update := bson.M{"$pull": bson.M{"orgowners": organization, "orgmembers": organization}}
	return m.collection.Update(qry, update)
}
607637
func (s *OrganizationService) FindOrganization(ctx context.Context, filter influxdb.OrganizationFilter) (*influxdb.Organization, error) {
	if filter.ID == nil && filter.Name == nil {
		return nil, &influxdb.Error{
			Code: influxdb.EInvalid,
			Msg:  "no filter parameters provided",
		}
	}
	os, n, err := s.FindOrganizations(ctx, filter)
	if err != nil {
		return nil, &influxdb.Error{
			Err: err,
			Op:  s.OpPrefix + influxdb.OpFindOrganization,
		}
	}

	if n == 0 {
		return nil, &influxdb.Error{
			Code: influxdb.ENotFound,
			Op:   s.OpPrefix + influxdb.OpFindOrganization,
			Msg:  "organization not found",
		}
	}

	return os[0], nil
}
1341560
func (s *DeregisterFromWorkMailInput) SetOrganizationId(v string) *DeregisterFromWorkMailInput {
	s.OrganizationId = &v
	return s
}
724081
func NewOrganizationService(context servicecontext.ServiceContext) service.OrganizationService {
	return &organizationServiceImpl{base.NewBaseService(context)}
}
201426
func (c *Client) FindOrganizationByID(ctx context.Context, id influxdb.ID) (*influxdb.Organization, error) {
	var o *influxdb.Organization
	err := c.db.View(func(tx *bolt.Tx) error {
		org, pe := c.findOrganizationByID(ctx, tx, id)
		if pe != nil {
			return &influxdb.Error{
				Op:  getOp(influxdb.OpFindOrganizationByID),
				Err: pe,
			}
		}
		o = org
		return nil
	})

	if err != nil {
		return nil, err
	}

	return o, nil
}
81548
func (s *DeleteNotificationSubscriptionInput) SetOrganizationId(v string) *DeleteNotificationSubscriptionInput {
	s.OrganizationId = &v
	return s
}
1056915
func (s *RegisterToWorkMailInput) SetOrganizationId(v string) *RegisterToWorkMailInput {
	s.OrganizationId = &v
	return s
}
308348
func (s *OrganizationService) FindOrganization(ctx context.Context, filter platform.OrganizationFilter) (*platform.Organization, error) {
	os, n, err := s.FindOrganizations(ctx, filter)
	if err != nil {
		return nil, &platform.Error{
			Err: err,
			Op:  s.OpPrefix + platform.OpFindOrganization,
		}
	}

	if n == 0 {
		return nil, &platform.Error{
			Code: platform.ENotFound,
			Op:   s.OpPrefix + platform.OpFindOrganization,
			Msg:  "organization not found",
		}
	}

	return os[0], nil
}
834425
func (s *DescribeOrganizationInput) SetOrganizationId(v string) *DescribeOrganizationInput {
	s.OrganizationId = &v
	return s
}