// AuthorizedWithOrgID adds the provided org as an owner of the document if
// the authorizer is allowed to access the org in being added.
350499
func AuthorizedWithOrgID(a Authorizer, orgID ID) func(ID, DocumentIndex) error {
	switch t := a.(type) {
	case *Authorization:
		return TokenAuthorizedWithOrgID(t, orgID)
	}

	return func(id ID, idx DocumentIndex) error {
		if err := idx.IsOrgAccessor(a.GetUserID(), orgID); err != nil {
			return err
		}

		return idx.AddDocumentOwner(id, "org", orgID)
	}
}
897316
func TokenAuthorizedWhereOrg(a *Authorization, org string) func(DocumentIndex, DocumentDecorator) ([]ID, error) {
	return func(idx DocumentIndex, _ DocumentDecorator) ([]ID, error) {
		oid, err := idx.FindOrganizationByName(org)
		if err != nil {
			return nil, err
		}
		return authorizedWhereOrgID(a, oid, idx)
	}
}
669514
func TokenAuthorizedWithOrgID(a *Authorization, orgID ID) func(ID, DocumentIndex) error {
	return func(id ID, idx DocumentIndex) error {
		if !a.IsActive() {
			return &Error{
				Code: EUnauthorized,
				Msg:  "authorization cannot add org as document owner",
			}
		}

		p := Permission{
			Action: WriteAction,
			Resource: Resource{
				Type:  DocumentsResourceType,
				OrgID: &orgID,
			},
		}

		if !a.Allowed(p) {
			return &Error{
				Code: EUnauthorized,
				Msg:  "authorization cannot add org as document owner",
			}
		}

		return idx.AddDocumentOwner(id, "org", orgID)
	}
}
308372
func (s *DescribeOrganizationOutput) SetOrganizationId(v string) *DescribeOrganizationOutput {
	s.OrganizationId = &v
	return s
}
797341
func AuthorizedWhereOrg(a Authorizer, org string) func(DocumentIndex, DocumentDecorator) ([]ID, error) {
	return func(idx DocumentIndex, _ DocumentDecorator) ([]ID, error) {
		oid, err := idx.FindOrganizationByName(org)
		if err != nil {
			return nil, err
		}
		return authorizedWhereOrgID(a, oid, idx)
	}
}
670518
func (s *AssociateMemberToGroupInput) SetOrganizationId(v string) *AssociateMemberToGroupInput {
	s.OrganizationId = &v
	return s
}
1056915
func (s *RegisterToWorkMailInput) SetOrganizationId(v string) *RegisterToWorkMailInput {
	s.OrganizationId = &v
	return s
}
679040
func authorizeOrg(certSubj pkix.Name, org string, blacklistedCerts map[string]*api.BlacklistedCertificate) (string, error) {
	if _, ok := blacklistedCerts[certSubj.CommonName]; ok {
		return "", status.Errorf(codes.PermissionDenied, "Permission denied: node %s was removed from swarm", certSubj.CommonName)
	}

	if len(certSubj.Organization) > 0 && certSubj.Organization[0] == org {
		return certSubj.CommonName, nil
	}

	return "", status.Errorf(codes.PermissionDenied, "Permission denied: remote certificate not part of organization: %s", org)
}
113918
func (s *OrgService) FindOrganizationByID(ctx context.Context, id influxdb.ID) (*influxdb.Organization, error) {
	if err := authorizeReadOrg(ctx, id); err != nil {
		return nil, err
	}

	return s.s.FindOrganizationByID(ctx, id)
}
1038240
func (s *GetRouteOutput) SetAuthorizerId(v string) *GetRouteOutput {
	s.AuthorizerId = &v
	return s
}
1113801
func WithRequestID(ctx context.Context, requestID string) context.Context {
	return context.WithValue(ctx, requestIDKey, requestID)
}
891234
func (s *PutAggregationAuthorizationInput) SetAuthorizedAccountId(v string) *PutAggregationAuthorizationInput {
	s.AuthorizedAccountId = &v
	return s
}
1083495
func (s *DescribeActivitiesInput) SetOrganizationId(v string) *DescribeActivitiesInput {
	s.OrganizationId = &v
	return s
}
73779
func (s *DeleteAliasInput) SetOrganizationId(v string) *DeleteAliasInput {
	s.OrganizationId = &v
	return s
}
967061
func (s *CreateRouteInput) SetAuthorizerId(v string) *CreateRouteInput {
	s.AuthorizerId = &v
	return s
}
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)
}
390114
func (s *ResetPasswordInput) SetOrganizationId(v string) *ResetPasswordInput {
	s.OrganizationId = &v
	return s
}