port-ocean 0.10.6__py3-none-any.whl → 0.10.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of port-ocean might be problematic. Click here for more details.

@@ -29,7 +29,7 @@ class EntityClientMixin:
29
29
  request_options: RequestOptions,
30
30
  user_agent_type: UserAgentType | None = None,
31
31
  should_raise: bool = True,
32
- ) -> Entity:
32
+ ) -> Entity | None:
33
33
  validation_only = request_options["validation_only"]
34
34
  async with self.semaphore:
35
35
  logger.debug(
@@ -58,9 +58,16 @@ class EntityClientMixin:
58
58
  )
59
59
  handle_status_code(response, should_raise)
60
60
  result = response.json()
61
+
61
62
  result_entity = (
62
63
  Entity.parse_obj(result["entity"]) if result.get("entity") else entity
63
64
  )
65
+
66
+ # Happens when upsert fails and search identifier is defined.
67
+ # We return None to ignore the entity later in the delete process
68
+ if result_entity.is_using_search_identifier:
69
+ return None
70
+
64
71
  # In order to save memory we'll keep only the identifier, blueprint and relations of the
65
72
  # upserted entity result for later calculations
66
73
  reduced_entity = Entity(
@@ -106,18 +106,27 @@ class HttpEntitiesStateApplier(BaseEntitiesStateApplier):
106
106
  should_raise=False,
107
107
  )
108
108
  else:
109
+ entities_with_search_identifier: list[Entity] = []
110
+ entities_without_search_identifier: list[Entity] = []
111
+ for entity in entities:
112
+ if entity.is_using_search_identifier:
113
+ entities_with_search_identifier.append(entity)
114
+ else:
115
+ entities_without_search_identifier.append(entity)
116
+
109
117
  ordered_created_entities = reversed(
110
- order_by_entities_dependencies(entities)
118
+ entities_with_search_identifier
119
+ + order_by_entities_dependencies(entities_without_search_identifier)
111
120
  )
112
121
  for entity in ordered_created_entities:
113
- modified_entities.append(
114
- await self.context.port_client.upsert_entity(
115
- entity,
116
- event.port_app_config.get_port_request_options(),
117
- user_agent_type,
118
- should_raise=False,
119
- )
122
+ upsertedEntity = await self.context.port_client.upsert_entity(
123
+ entity,
124
+ event.port_app_config.get_port_request_options(),
125
+ user_agent_type,
126
+ should_raise=False,
120
127
  )
128
+ if upsertedEntity:
129
+ modified_entities.append(upsertedEntity)
121
130
  return modified_entities
122
131
 
123
132
  async def delete(
@@ -13,18 +13,22 @@ class Rule(BaseModel):
13
13
  value: str
14
14
 
15
15
 
16
- class SearchRelation(BaseModel):
16
+ class IngestSearchQuery(BaseModel):
17
17
  combinator: str
18
- rules: list[Rule | SearchRelation]
18
+ rules: list[Rule | IngestSearchQuery]
19
19
 
20
20
 
21
21
  class EntityMapping(BaseModel):
22
- identifier: str
22
+ identifier: str | IngestSearchQuery
23
23
  title: str | None
24
24
  blueprint: str
25
25
  team: str | None
26
26
  properties: dict[str, str] = Field(default_factory=dict)
27
- relations: dict[str, str | SearchRelation] = Field(default_factory=dict)
27
+ relations: dict[str, str | IngestSearchQuery] = Field(default_factory=dict)
28
+
29
+ @property
30
+ def is_using_search_identifier(self) -> bool:
31
+ return isinstance(self.identifier, dict)
28
32
 
29
33
 
30
34
  class MappingsConfig(BaseModel):
@@ -154,6 +154,12 @@ class SyncRawMixin(HandlerMixin, EventsMixin):
154
154
  results: list[RAW_ITEM],
155
155
  user_agent_type: UserAgentType,
156
156
  ) -> tuple[list[Entity], list[Exception]]:
157
+ if resource.port.entity.mappings.is_using_search_identifier:
158
+ logger.info(
159
+ f"Skip unregistering resource of kind {resource.kind}, as mapping defined with search identifier"
160
+ )
161
+ return [], []
162
+
157
163
  objects_diff = await self._calculate_raw([(resource, results)])
158
164
  entities_selector_diff, errors = objects_diff[0]
159
165
 
@@ -272,7 +278,8 @@ class SyncRawMixin(HandlerMixin, EventsMixin):
272
278
  [
273
279
  entity
274
280
  for entity in entities_to_delete
275
- if (entity.identifier, entity.blueprint)
281
+ if not entity.is_using_search_identifier
282
+ and (entity.identifier, entity.blueprint)
276
283
  not in registered_entities_attributes
277
284
  ],
278
285
  )
port_ocean/core/models.py CHANGED
@@ -19,6 +19,10 @@ class Entity(BaseModel):
19
19
  properties: dict[str, Any] = {}
20
20
  relations: dict[str, Any] = {}
21
21
 
22
+ @property
23
+ def is_using_search_identifier(self) -> bool:
24
+ return isinstance(self.identifier, dict)
25
+
22
26
 
23
27
  class BlueprintRelation(BaseModel):
24
28
  many: bool
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: port-ocean
3
- Version: 0.10.6
3
+ Version: 0.10.7
4
4
  Summary: Port Ocean is a CLI tool for managing your Port projects.
5
5
  Home-page: https://app.getport.io
6
6
  Keywords: ocean,port-ocean,port
@@ -44,7 +44,7 @@ port_ocean/clients/port/authentication.py,sha256=t3z6h4vld-Tzkpth15sstaMJg0rccX-
44
44
  port_ocean/clients/port/client.py,sha256=Xd8Jk25Uh4WXY_WW-z1Qbv6F3ZTBFPoOolsxHMfozKw,3366
45
45
  port_ocean/clients/port/mixins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
46
  port_ocean/clients/port/mixins/blueprints.py,sha256=8ZVC5i8K1WKQMJJiPqZmgcOlF3OyxWz1aAQ_WA5UW3c,4500
47
- port_ocean/clients/port/mixins/entities.py,sha256=oyd1mVlaoRnQLMpN9oOuYOC2PqLTMfJ51Z7cNyuVNNc,8647
47
+ port_ocean/clients/port/mixins/entities.py,sha256=HiOjAaIo5qaf9fcOgVKufYiSsBnTRaDNnskgs-7DSOI,8878
48
48
  port_ocean/clients/port/mixins/integrations.py,sha256=HnWXaJt41SUcha-bhvLdJW07j-l7xIo91GUzzwl2f_E,4859
49
49
  port_ocean/clients/port/mixins/migrations.py,sha256=A6896oJF6WbFL2WroyTkMzr12yhVyWqGoq9dtLNSKBY,1457
50
50
  port_ocean/clients/port/retry_transport.py,sha256=PtIZOAZ6V-ncpVysRUsPOgt8Sf01QLnTKB5YeKBxkJk,1861
@@ -77,7 +77,7 @@ port_ocean/core/handlers/base.py,sha256=cTarblazu8yh8xz2FpB-dzDKuXxtoi143XJgPbV_
77
77
  port_ocean/core/handlers/entities_state_applier/__init__.py,sha256=kgLZDCeCEzi4r-0nzW9k78haOZNf6PX7mJOUr34A4c8,173
78
78
  port_ocean/core/handlers/entities_state_applier/base.py,sha256=5wHL0icfFAYRPqk8iV_wN49GdJ3aRUtO8tumSxBi4Wo,2268
79
79
  port_ocean/core/handlers/entities_state_applier/port/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
80
- port_ocean/core/handlers/entities_state_applier/port/applier.py,sha256=fZzaz8idbZQhYz_dqohNvoRWGdET_cYHZDenQmnkdCA,5438
80
+ port_ocean/core/handlers/entities_state_applier/port/applier.py,sha256=EirgWhT_TNeEwfdCElEDGkJ2tSOz9HsaUJ1i2uD7z28,5922
81
81
  port_ocean/core/handlers/entities_state_applier/port/get_related_entities.py,sha256=1zncwCbE-Gej0xaWKlzZgoXxOBe9bgs_YxlZ8QW3NdI,1751
82
82
  port_ocean/core/handlers/entities_state_applier/port/order_by_entities_dependencies.py,sha256=82BvU8t5w9uhsxX8hbnwuRPuWhW3cMeuT_5sVIkip1I,1550
83
83
  port_ocean/core/handlers/entity_processor/__init__.py,sha256=FvFCunFg44wNQoqlybem9MthOs7p1Wawac87uSXz9U8,156
@@ -86,7 +86,7 @@ port_ocean/core/handlers/entity_processor/jq_entity_processor.py,sha256=_nQtlY0Z
86
86
  port_ocean/core/handlers/port_app_config/__init__.py,sha256=8AAT5OthiVM7KCcM34iEgEeXtn2pRMrT4Dze5r1Ixbk,134
87
87
  port_ocean/core/handlers/port_app_config/api.py,sha256=6VbKPwFzsWG0IYsVD81hxSmfqtHUFqrfUuj1DBX5g4w,853
88
88
  port_ocean/core/handlers/port_app_config/base.py,sha256=4Nxt2g8voEIHJ4Y1Km5NJcaG2iSbCklw5P8-Kus7Y9k,3007
89
- port_ocean/core/handlers/port_app_config/models.py,sha256=4dw6HbgjMG3advpN3x6XF35xsgScnWm0KKTERG4CYZ8,2201
89
+ port_ocean/core/handlers/port_app_config/models.py,sha256=YvYtf_44KD_rN4xK-3xHtdpRZ1M8Qo-m9K4LDtH7FYU,2344
90
90
  port_ocean/core/handlers/resync_state_updater/__init__.py,sha256=kG6y-JQGpPfuTHh912L_bctIDCzAK4DN-d00S7rguWU,81
91
91
  port_ocean/core/handlers/resync_state_updater/updater.py,sha256=Yg9ET6ZV5B9GW7u6zZA6GlB_71kmvxvYX2FWgQNzMvo,3182
92
92
  port_ocean/core/integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -95,9 +95,9 @@ port_ocean/core/integrations/mixins/__init__.py,sha256=FA1FEKMM6P-L2_m7Q4L20mFa4
95
95
  port_ocean/core/integrations/mixins/events.py,sha256=Ddfx2L4FpghV38waF8OfVeOV0bHBxNIgjU-q5ffillI,2341
96
96
  port_ocean/core/integrations/mixins/handler.py,sha256=mZ7-0UlG3LcrwJttFbMe-R4xcOU2H_g33tZar7PwTv8,3771
97
97
  port_ocean/core/integrations/mixins/sync.py,sha256=B9fEs8faaYLLikH9GBjE_E61vo0bQDjIGQsQ1SRXOlA,3931
98
- port_ocean/core/integrations/mixins/sync_raw.py,sha256=2vyHhGWyPchVfSUKRRfSJ2XsX55ygLWCFrKDaqkNd0o,18386
98
+ port_ocean/core/integrations/mixins/sync_raw.py,sha256=nPYlUTQdh6HDIqBwh3jQ-hmraNx4CeSK9YQ98NTonbQ,18697
99
99
  port_ocean/core/integrations/mixins/utils.py,sha256=7y1rGETZIjOQadyIjFJXIHKkQFKx_SwiP-TrAIsyyLY,2303
100
- port_ocean/core/models.py,sha256=8yYyF4DQ4jMmQJPsmh5-XoF9gfHUTuBit6zuT-bxZ7Y,1228
100
+ port_ocean/core/models.py,sha256=dJ2_olTdbjUpObQJNmg7e7EENU_zZiX6XOaknNp54B0,1342
101
101
  port_ocean/core/ocean_types.py,sha256=3_d8-n626f1kWLQ_Jxw194LEyrOVupz05qs_Y1pvB-A,990
102
102
  port_ocean/core/utils.py,sha256=40UjRauRJO47WDSNn9bkCRD2bfhfB3e-dnOLULnuVzE,3631
103
103
  port_ocean/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -133,8 +133,8 @@ port_ocean/utils/repeat.py,sha256=0EFWM9d8lLXAhZmAyczY20LAnijw6UbIECf5lpGbOas,32
133
133
  port_ocean/utils/signal.py,sha256=K-6kKFQTltcmKDhtyZAcn0IMa3sUpOHGOAUdWKgx0_E,1369
134
134
  port_ocean/utils/time.py,sha256=pufAOH5ZQI7gXvOvJoQXZXZJV-Dqktoj9Qp9eiRwmJ4,1939
135
135
  port_ocean/version.py,sha256=UsuJdvdQlazzKGD3Hd5-U7N69STh8Dq9ggJzQFnu9fU,177
136
- port_ocean-0.10.6.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
137
- port_ocean-0.10.6.dist-info/METADATA,sha256=bU-QFO_CsBFDwaEVaDqlBctyNMbrlIM7DGbjyhh-JVU,6616
138
- port_ocean-0.10.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
139
- port_ocean-0.10.6.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
140
- port_ocean-0.10.6.dist-info/RECORD,,
136
+ port_ocean-0.10.7.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
137
+ port_ocean-0.10.7.dist-info/METADATA,sha256=icaP14jRpY9Mn-Sk7pk7rZdhwga5WbEBiuaFOpOdk7E,6616
138
+ port_ocean-0.10.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
139
+ port_ocean-0.10.7.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
140
+ port_ocean-0.10.7.dist-info/RECORD,,