// OrganizationConfig retrieves the organization-wide config settings
518645
func (s *Service) OrganizationConfig(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()

	orgID, ok := hasOrganizationContext(ctx)
	if !ok {
		Error(w, http.StatusBadRequest, "Organization not found on context", s.Logger)
		return
	}

	config, err := s.Store.OrganizationConfig(ctx).FindOrCreate(ctx, orgID)
	if err != nil {
		Error(w, http.StatusBadRequest, err.Error(), s.Logger)
		return
	}

	res := newOrganizationConfigResponse(*config)
	encodeJSON(w, http.StatusOK, res, s.Logger)
}
651375
func (s *Store) Config(service string) *discoverd.ServiceConfig {
	s.mu.RLock()
	defer s.mu.RUnlock()
	return s.data.Services[service]
}
1083841
func (s *User) SetOrganizationId(v string) *User {
	s.OrganizationId = &v
	return s
}
1240048
func (s *Store) OrganizationConfig(ctx context.Context) chronograf.OrganizationConfigStore {
	if orgID, ok := hasOrganizationContext(ctx); ok {
		return organizations.NewOrganizationConfigStore(s.OrganizationConfigStore, orgID)
	}

	return &noop.OrganizationConfigStore{}
}
705850
func (s *OrganizationConfigStore) Get(ctx context.Context, orgID string) (*chronograf.OrganizationConfig, error) {
	var c chronograf.OrganizationConfig

	err := s.client.db.View(func(tx *bolt.Tx) error {
		return s.get(ctx, tx, orgID, &c)
	})

	if err != nil {
		return nil, err
	}

	return &c, nil
}
1268240
func NewOrganizationService() *OrganizationService {
	return &OrganizationService{
		FindOrganizationByIDF: func(ctx context.Context, id platform.ID) (*platform.Organization, error) { return nil, nil },
		FindOrganizationF: func(ctx context.Context, filter platform.OrganizationFilter) (*platform.Organization, error) {
			return nil, nil
		},
		FindOrganizationsF: func(ctx context.Context, filter platform.OrganizationFilter, opt ...platform.FindOptions) ([]*platform.Organization, int, error) {
			return nil, 0, nil
		},
		CreateOrganizationF: func(ctx context.Context, b *platform.Organization) error { return nil },
		UpdateOrganizationF: func(ctx context.Context, id platform.ID, upd platform.OrganizationUpdate) (*platform.Organization, error) {
			return nil, nil
		},
		DeleteOrganizationF: func(ctx context.Context, id platform.ID) error { return nil },
	}
}
808439
func (r *Resources) ApplicationConfig() (channelconfig.Application, bool) {
	return r.ApplicationConfigVal, r.ApplicationConfigVal != nil
}
955683
func (s *Service) ReplaceOrganizationLogViewerConfig(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()

	orgID, ok := hasOrganizationContext(ctx)
	if !ok {
		Error(w, http.StatusBadRequest, "Organization not found on context", s.Logger)
		return
	}

	var logViewerConfig chronograf.LogViewerConfig
	if err := json.NewDecoder(r.Body).Decode(&logViewerConfig); err != nil {
		invalidJSON(w, s.Logger)
		return
	}
	if err := validLogViewerConfig(logViewerConfig); err != nil {
		Error(w, http.StatusBadRequest, err.Error(), s.Logger)
		return
	}

	config, err := s.Store.OrganizationConfig(ctx).FindOrCreate(ctx, orgID)
	if err != nil {
		Error(w, http.StatusBadRequest, err.Error(), s.Logger)
		return
	}
	config.LogViewer = logViewerConfig
	if err := s.Store.OrganizationConfig(ctx).Put(ctx, config); err != nil {
		unknownErrorWithMessage(w, err, s.Logger)
		return
	}

	res := newLogViewerConfigResponse(config.LogViewer)
	encodeJSON(w, http.StatusOK, res, s.Logger)
}
284248
func (s *OrganizationService) FindOrganizations(ctx context.Context, filter platform.OrganizationFilter, opt ...platform.FindOptions) ([]*platform.Organization, int, error) {
	return s.FindOrganizationsF(ctx, filter, opt...)
}
813017
func (s *Service) OrganizationPreferencesUpdate(ctx context.Context, organizationPreferencesIdentity string, o OrganizationPreferencesUpdateOpts) (*OrganizationPreferences, error) {
	var organizationPreferences OrganizationPreferences
	return &organizationPreferences, s.Patch(ctx, &organizationPreferences, fmt.Sprintf("/organizations/%v/preferences", organizationPreferencesIdentity), o)
}
296959
func (s *UpdateServiceSettingsInput) SetOrganizationConfiguration(v *OrganizationConfiguration) *UpdateServiceSettingsInput {
	s.OrganizationConfiguration = v
	return s
}
118025
func (s *Service) OrganizationPreferencesList(ctx context.Context, organizationPreferencesIdentity string) (*OrganizationPreferences, error) {
	var organizationPreferences OrganizationPreferences
	return &organizationPreferences, s.Get(ctx, &organizationPreferences, fmt.Sprintf("/organizations/%v/preferences", organizationPreferencesIdentity), nil, nil)
}
1122718
func (s *Service) OrganizationDelete(ctx context.Context, organizationIdentity string) (*Organization, error) {
	var organization Organization
	return &organization, s.Delete(ctx, &organization, fmt.Sprintf("/organizations/%v", organizationIdentity))
}
7746
func (u *UniterAPIV4) NetworkConfig(args params.UnitsNetworkConfig) (params.UnitNetworkConfigResults, error) {
	result := params.UnitNetworkConfigResults{
		Results: make([]params.UnitNetworkConfigResult, len(args.Args)),
	}

	canAccess, err := u.accessUnit()
	if err != nil {
		return params.UnitNetworkConfigResults{}, err
	}

	for i, arg := range args.Args {
		netConfig, err := u.getOneNetworkConfig(canAccess, arg.UnitTag, arg.BindingName)
		if err == nil {
			result.Results[i].Config = netConfig
		} else {
			result.Results[i].Error = common.ServerError(err)
		}
	}
	return result, nil
}
558861
func (p *Project) Config() (string, error) {
	cfg := ExportedConfig{
		Version:  "2.0",
		Services: p.ServiceConfigs.All(),
		Volumes:  p.VolumeConfigs,
		Networks: p.NetworkConfigs,
	}

	bytes, err := yaml.Marshal(cfg)
	return string(bytes), err
}
1056329
func (s *CreateGroupInput) SetOrganizationId(v string) *CreateGroupInput {
	s.OrganizationId = &v
	return s
}
1041062
func MarshalOrganizationConfig(c *chronograf.OrganizationConfig) ([]byte, error) {
	columns := make([]*LogViewerColumn, len(c.LogViewer.Columns))

	for i, column := range c.LogViewer.Columns {
		encodings := make([]*ColumnEncoding, len(column.Encodings))

		for j, e := range column.Encodings {
			encodings[j] = &ColumnEncoding{
				Type:  e.Type,
				Value: e.Value,
				Name:  e.Name,
			}
		}

		columns[i] = &LogViewerColumn{
			Name:      column.Name,
			Position:  column.Position,
			Encodings: encodings,
		}
	}

	return MarshalOrganizationConfigPB(&OrganizationConfig{
		OrganizationID: c.OrganizationID,
		LogViewer: &LogViewerConfig{
			Columns: columns,
		},
	})
}