Skip to content

Commit

Permalink
Merge branch 'datahub-project:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
anshbansal authored Mar 21, 2024
2 parents ee7d041 + 9659d60 commit 17df123
Show file tree
Hide file tree
Showing 163 changed files with 9,486 additions and 1,844 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import com.linkedin.datahub.graphql.generated.Dataset;
import com.linkedin.datahub.graphql.generated.DatasetStatsSummary;
import com.linkedin.datahub.graphql.generated.Domain;
import com.linkedin.datahub.graphql.generated.ERModelRelationshipProperties;
import com.linkedin.datahub.graphql.generated.EntityPath;
import com.linkedin.datahub.graphql.generated.EntityRelationship;
import com.linkedin.datahub.graphql.generated.EntityRelationshipLegacy;
Expand Down Expand Up @@ -256,6 +257,7 @@
import com.linkedin.datahub.graphql.resolvers.settings.view.UpdateGlobalViewsSettingsResolver;
import com.linkedin.datahub.graphql.resolvers.step.BatchGetStepStatesResolver;
import com.linkedin.datahub.graphql.resolvers.step.BatchUpdateStepStatesResolver;
import com.linkedin.datahub.graphql.resolvers.structuredproperties.UpsertStructuredPropertiesResolver;
import com.linkedin.datahub.graphql.resolvers.tag.CreateTagResolver;
import com.linkedin.datahub.graphql.resolvers.tag.DeleteTagResolver;
import com.linkedin.datahub.graphql.resolvers.tag.SetTagColorResolver;
Expand Down Expand Up @@ -308,6 +310,9 @@
import com.linkedin.datahub.graphql.types.datatype.DataTypeType;
import com.linkedin.datahub.graphql.types.domain.DomainType;
import com.linkedin.datahub.graphql.types.entitytype.EntityTypeType;
import com.linkedin.datahub.graphql.types.ermodelrelationship.CreateERModelRelationshipResolver;
import com.linkedin.datahub.graphql.types.ermodelrelationship.ERModelRelationshipType;
import com.linkedin.datahub.graphql.types.ermodelrelationship.UpdateERModelRelationshipResolver;
import com.linkedin.datahub.graphql.types.form.FormType;
import com.linkedin.datahub.graphql.types.glossary.GlossaryNodeType;
import com.linkedin.datahub.graphql.types.glossary.GlossaryTermType;
Expand Down Expand Up @@ -346,6 +351,7 @@
import com.linkedin.metadata.recommendation.RecommendationsService;
import com.linkedin.metadata.secret.SecretService;
import com.linkedin.metadata.service.DataProductService;
import com.linkedin.metadata.service.ERModelRelationshipService;
import com.linkedin.metadata.service.FormService;
import com.linkedin.metadata.service.LineageService;
import com.linkedin.metadata.service.OwnershipTypeService;
Expand Down Expand Up @@ -417,6 +423,7 @@ public class GmsGraphQLEngine {
private final LineageService lineageService;
private final QueryService queryService;
private final DataProductService dataProductService;
private final ERModelRelationshipService erModelRelationshipService;
private final FormService formService;
private final RestrictedService restrictedService;

Expand Down Expand Up @@ -462,6 +469,7 @@ public class GmsGraphQLEngine {
private final DataHubPolicyType dataHubPolicyType;
private final DataHubRoleType dataHubRoleType;
private final SchemaFieldType schemaFieldType;
private final ERModelRelationshipType erModelRelationshipType;
private final DataHubViewType dataHubViewType;
private final QueryType queryType;
private final DataProductType dataProductType;
Expand Down Expand Up @@ -529,6 +537,7 @@ public GmsGraphQLEngine(final GmsGraphQLEngineArgs args) {
this.settingsService = args.settingsService;
this.lineageService = args.lineageService;
this.queryService = args.queryService;
this.erModelRelationshipService = args.erModelRelationshipService;
this.dataProductService = args.dataProductService;
this.formService = args.formService;
this.restrictedService = args.restrictedService;
Expand Down Expand Up @@ -572,6 +581,7 @@ public GmsGraphQLEngine(final GmsGraphQLEngineArgs args) {
this.dataHubPolicyType = new DataHubPolicyType(entityClient);
this.dataHubRoleType = new DataHubRoleType(entityClient);
this.schemaFieldType = new SchemaFieldType(entityClient, featureFlags);
this.erModelRelationshipType = new ERModelRelationshipType(entityClient, featureFlags);
this.dataHubViewType = new DataHubViewType(entityClient);
this.queryType = new QueryType(entityClient);
this.dataProductType = new DataProductType(entityClient);
Expand Down Expand Up @@ -617,6 +627,7 @@ public GmsGraphQLEngine(final GmsGraphQLEngineArgs args) {
dataHubPolicyType,
dataHubRoleType,
schemaFieldType,
erModelRelationshipType,
dataHubViewType,
queryType,
dataProductType,
Expand Down Expand Up @@ -707,6 +718,7 @@ public void configureRuntimeWiring(final RuntimeWiring.Builder builder) {
configureTestResultResolvers(builder);
configureRoleResolvers(builder);
configureSchemaFieldResolvers(builder);
configureERModelRelationshipResolvers(builder);
configureEntityPathResolvers(builder);
configureResolvedAuditStampResolvers(builder);
configureViewResolvers(builder);
Expand Down Expand Up @@ -833,6 +845,7 @@ private void configureContainerResolvers(final RuntimeWiring.Builder builder) {
typeWiring
.dataFetcher("relationships", new EntityRelationshipsResultResolver(graphClient))
.dataFetcher("entities", new ContainerEntitiesResolver(entityClient))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher(
"aspects", new WeaklyTypedAspectsResolver(entityClient, entityRegistry))
.dataFetcher("exists", new EntityExistsResolver(entityService))
Expand Down Expand Up @@ -939,6 +952,7 @@ private void configureQueryResolvers(final RuntimeWiring.Builder builder) {
.dataFetcher("glossaryTerm", getResolver(glossaryTermType))
.dataFetcher("glossaryNode", getResolver(glossaryNodeType))
.dataFetcher("domain", getResolver((domainType)))
.dataFetcher("erModelRelationship", getResolver(erModelRelationshipType))
.dataFetcher("dataPlatform", getResolver(dataPlatformType))
.dataFetcher("dataPlatformInstance", getResolver(dataPlatformInstanceType))
.dataFetcher("mlFeatureTable", getResolver(mlFeatureTableType))
Expand Down Expand Up @@ -1069,6 +1083,13 @@ private void configureMutationResolvers(final RuntimeWiring.Builder builder) {
.dataFetcher("updateDataFlow", new MutableTypeResolver<>(dataFlowType))
.dataFetcher("updateCorpUserProperties", new MutableTypeResolver<>(corpUserType))
.dataFetcher("updateCorpGroupProperties", new MutableTypeResolver<>(corpGroupType))
.dataFetcher(
"updateERModelRelationship",
new UpdateERModelRelationshipResolver(this.entityClient))
.dataFetcher(
"createERModelRelationship",
new CreateERModelRelationshipResolver(
this.entityClient, this.erModelRelationshipService))
.dataFetcher("addTag", new AddTagResolver(entityService))
.dataFetcher("addTags", new AddTagsResolver(entityService))
.dataFetcher("batchAddTags", new BatchAddTagsResolver(entityService))
Expand Down Expand Up @@ -1224,6 +1245,9 @@ private void configureMutationResolvers(final RuntimeWiring.Builder builder) {
.dataFetcher(
"verifyForm", new VerifyFormResolver(this.formService, this.groupService))
.dataFetcher("batchRemoveForm", new BatchRemoveFormResolver(this.formService))
.dataFetcher(
"upsertStructuredProperties",
new UpsertStructuredPropertiesResolver(this.entityClient))
.dataFetcher("raiseIncident", new RaiseIncidentResolver(this.entityClient))
.dataFetcher(
"updateIncidentStatus",
Expand Down Expand Up @@ -1700,6 +1724,7 @@ private void configureCorpUserResolvers(final RuntimeWiring.Builder builder) {
typeWiring ->
typeWiring
.dataFetcher("relationships", new EntityRelationshipsResultResolver(graphClient))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher(
"aspects", new WeaklyTypedAspectsResolver(entityClient, entityRegistry)));
builder.type(
Expand All @@ -1722,6 +1747,7 @@ private void configureCorpGroupResolvers(final RuntimeWiring.Builder builder) {
typeWiring ->
typeWiring
.dataFetcher("relationships", new EntityRelationshipsResultResolver(graphClient))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher(
"aspects", new WeaklyTypedAspectsResolver(entityClient, entityRegistry))
.dataFetcher("exists", new EntityExistsResolver(entityService)));
Expand Down Expand Up @@ -2078,6 +2104,60 @@ private void configureTypeExtensions(final RuntimeWiring.Builder builder) {
builder.scalar(GraphQLLong);
}

/** Configures resolvers responsible for resolving the {@link ERModelRelationship} type. */
private void configureERModelRelationshipResolvers(final RuntimeWiring.Builder builder) {
builder
.type(
"ERModelRelationship",
typeWiring ->
typeWiring
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher(
"relationships", new EntityRelationshipsResultResolver(graphClient)))
.type(
"ERModelRelationshipProperties",
typeWiring ->
typeWiring
.dataFetcher(
"source",
new LoadableTypeResolver<>(
datasetType,
(env) -> {
final ERModelRelationshipProperties erModelRelationshipProperties =
env.getSource();
return erModelRelationshipProperties.getSource() != null
? erModelRelationshipProperties.getSource().getUrn()
: null;
}))
.dataFetcher(
"destination",
new LoadableTypeResolver<>(
datasetType,
(env) -> {
final ERModelRelationshipProperties erModelRelationshipProperties =
env.getSource();
return erModelRelationshipProperties.getDestination() != null
? erModelRelationshipProperties.getDestination().getUrn()
: null;
})))
.type(
"Owner",
typeWiring ->
typeWiring.dataFetcher(
"owner",
new OwnerTypeResolver<>(
ownerTypes, (env) -> ((Owner) env.getSource()).getOwner())))
.type(
"InstitutionalMemoryMetadata",
typeWiring ->
typeWiring.dataFetcher(
"author",
new LoadableTypeResolver<>(
corpUserType,
(env) ->
((InstitutionalMemoryMetadata) env.getSource()).getAuthor().getUrn())));
}

/**
* Configures resolvers responsible for resolving the {@link
* com.linkedin.datahub.graphql.generated.DataJob} type.
Expand Down Expand Up @@ -2180,6 +2260,7 @@ private void configureDataFlowResolvers(final RuntimeWiring.Builder builder) {
dataPlatformType,
(env) -> ((DataFlow) env.getSource()).getPlatform().getUrn()))
.dataFetcher("exists", new EntityExistsResolver(entityService))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher(
"dataPlatformInstance",
new LoadableTypeResolver<>(
Expand Down Expand Up @@ -2227,6 +2308,7 @@ private void configureMLFeatureTableResolvers(final RuntimeWiring.Builder builde
new LoadableTypeResolver<>(
dataPlatformType,
(env) -> ((MLFeatureTable) env.getSource()).getPlatform().getUrn()))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher(
"dataPlatformInstance",
new LoadableTypeResolver<>(
Expand Down Expand Up @@ -2317,6 +2399,7 @@ private void configureMLFeatureTableResolvers(final RuntimeWiring.Builder builde
new LoadableTypeResolver<>(
dataPlatformType,
(env) -> ((MLModel) env.getSource()).getPlatform().getUrn()))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher(
"dataPlatformInstance",
new LoadableTypeResolver<>(
Expand Down Expand Up @@ -2365,6 +2448,7 @@ private void configureMLFeatureTableResolvers(final RuntimeWiring.Builder builde
dataPlatformType,
(env) -> ((MLModelGroup) env.getSource()).getPlatform().getUrn()))
.dataFetcher("exists", new EntityExistsResolver(entityService))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher(
"dataPlatformInstance",
new LoadableTypeResolver<>(
Expand All @@ -2390,6 +2474,7 @@ private void configureMLFeatureTableResolvers(final RuntimeWiring.Builder builde
.dataFetcher(
"aspects", new WeaklyTypedAspectsResolver(entityClient, entityRegistry))
.dataFetcher("exists", new EntityExistsResolver(entityService))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher(
"dataPlatformInstance",
new LoadableTypeResolver<>(
Expand All @@ -2406,6 +2491,7 @@ private void configureMLFeatureTableResolvers(final RuntimeWiring.Builder builde
typeWiring
.dataFetcher(
"relationships", new EntityRelationshipsResultResolver(graphClient))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher(
"lineage",
new EntityLineageResultResolver(
Expand Down Expand Up @@ -2448,6 +2534,7 @@ private void configureDomainResolvers(final RuntimeWiring.Builder builder) {
typeWiring
.dataFetcher("entities", new DomainEntitiesResolver(this.entityClient))
.dataFetcher("parentDomains", new ParentDomainsResolver(this.entityClient))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher(
"aspects", new WeaklyTypedAspectsResolver(entityClient, entityRegistry))
.dataFetcher("relationships", new EntityRelationshipsResultResolver(graphClient)));
Expand Down Expand Up @@ -2520,6 +2607,7 @@ private void configureDataProductResolvers(final RuntimeWiring.Builder builder)
typeWiring ->
typeWiring
.dataFetcher("entities", new ListDataProductAssetsResolver(this.entityClient))
.dataFetcher("privileges", new EntityPrivilegesResolver(entityClient))
.dataFetcher(
"aspects", new WeaklyTypedAspectsResolver(entityClient, entityRegistry))
.dataFetcher("relationships", new EntityRelationshipsResultResolver(graphClient)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.linkedin.metadata.recommendation.RecommendationsService;
import com.linkedin.metadata.secret.SecretService;
import com.linkedin.metadata.service.DataProductService;
import com.linkedin.metadata.service.ERModelRelationshipService;
import com.linkedin.metadata.service.FormService;
import com.linkedin.metadata.service.LineageService;
import com.linkedin.metadata.service.OwnershipTypeService;
Expand Down Expand Up @@ -75,6 +76,7 @@ public class GmsGraphQLEngineArgs {
QueryService queryService;
FeatureFlags featureFlags;
DataProductService dataProductService;
ERModelRelationshipService erModelRelationshipService;
FormService formService;
RestrictedService restrictedService;
int graphQLQueryComplexityLimit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,24 @@ public static boolean canManageOwnershipTypes(@Nonnull QueryContext context) {
return isAuthorized(context, Optional.empty(), PoliciesConfig.MANAGE_GLOBAL_OWNERSHIP_TYPES);
}

public static boolean canEditProperties(@Nonnull Urn targetUrn, @Nonnull QueryContext context) {
// If you either have all entity privileges, or have the specific privileges required, you are
// authorized.
final DisjunctivePrivilegeGroup orPrivilegeGroups =
new DisjunctivePrivilegeGroup(
ImmutableList.of(
ALL_PRIVILEGES_GROUP,
new ConjunctivePrivilegeGroup(
ImmutableList.of(PoliciesConfig.EDIT_ENTITY_PROPERTIES_PRIVILEGE.getType()))));

return AuthorizationUtils.isAuthorized(
context.getAuthorizer(),
context.getActorUrn(),
targetUrn.getEntityType(),
targetUrn.toString(),
orPrivilegeGroups);
}

public static boolean canEditEntityQueries(
@Nonnull List<Urn> entityUrns, @Nonnull QueryContext context) {
final DisjunctivePrivilegeGroup orPrivilegeGroups =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class FeatureFlags {
private boolean platformBrowseV2 = false;
private PreProcessHooks preProcessHooks;
private boolean showAcrylInfo = false;
private boolean erModelRelationshipFeatureEnabled = false;
private boolean showAccessManagement = false;
private boolean nestedDomainsEnabled = false;
private boolean schemaFieldEntityFetchEnabled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ public CompletableFuture<AppConfig> get(final DataFetchingEnvironment environmen
.setReadOnlyModeEnabled(_featureFlags.isReadOnlyModeEnabled())
.setShowBrowseV2(_featureFlags.isShowBrowseV2())
.setShowAcrylInfo(_featureFlags.isShowAcrylInfo())
.setErModelRelationshipFeatureEnabled(
_featureFlags.isErModelRelationshipFeatureEnabled())
.setShowAccessManagement(_featureFlags.isShowAccessManagement())
.setNestedDomainsEnabled(_featureFlags.isNestedDomainsEnabled())
.setPlatformBrowseV2(_featureFlags.isPlatformBrowseV2())
Expand Down Expand Up @@ -262,6 +264,10 @@ private EntityType mapResourceTypeToEntityType(final String resourceType) {
.getResourceType()
.equals(resourceType)) {
return EntityType.CORP_USER;
} else if (com.linkedin.metadata.authorization.PoliciesConfig.ER_MODEL_RELATIONSHIP_PRIVILEGES
.getResourceType()
.equals(resourceType)) {
return EntityType.ER_MODEL_RELATIONSHIP;
} else {
return null;
}
Expand Down
Loading

0 comments on commit 17df123

Please sign in to comment.