Skip to content

Deployed Items

A deployed item holds the provisioning output produced when a service owner fulfils a change instance — connection strings, IP addresses, hostnames, credentials, or any structured data that the consumer needs to use the service.

Accessed via client.deployed_items. A ServiceItem instance can also create, fetch, and update its own deployed items directly — see Service Items: Deployed item instance methods.

Model properties

Property Type Description
id int Deployed item ID
name str Deployed item name
service_item_id int Associated service item ID
change_instance_id int The change instance that created this item
data_field dict The provisioning payload (connection info, config, etc.) — accesses the data field in the API response
created datetime Creation timestamp
modified datetime Last modified timestamp

Methods

list(**filters)

Returns a lazy generator of deployed items. Use for large result sets.

Filters:

Filter Type Description
ordering str Sort field — prefix with - for descending (e.g. -created)
# All deployed items
for item in client.deployed_items.list():
    print(item.id, item.name)

# Most recently created first
for item in client.deployed_items.list(ordering="-created"):
    print(item.id, item.created)

filter(**filters)

Same as list() but returns all results as a list. Accepts the same filters.

items = client.deployed_items.filter(ordering="-created")
print(f"Found {len(items)} deployed items")

get(id)

Retrieves a single deployed item by ID. Raises NetorcaNotFoundError if not found.

item = client.deployed_items.get(789)

print(item.id)
print(item.name)
print(item.service_item_id)
print(item.change_instance_id)
print(item.data_field)    # the provisioning payload
print(item.created)
print(item.modified)

# Access any API field not exposed as a property
print(item.data['version'])  # version number of the deployed item

create(service_item_id=None, change_instance_id=None, data=None)

Creates a deployed item to record the output of a provisioning operation. This is how a service owner records what was actually deployed in response to a change instance.

service_item_id/change_instance_id accept either a plain int ID (resolved to the resource's URL with an extra GET before the deployed item is created) or the resource URL directly (skips that lookup) — service_item/change_instance are hyperlinked relations on the API, not bare IDs, so the SDK does the lookup for you. At least one of the two is required.

Parameter Type Required Description
service_item_id int or str one of the two ID or URL of the service item being fulfilled
change_instance_id int or str one of the two ID or URL of the change instance being resolved
data dict yes The provisioning payload to upload — any structure you choose
# Using an ID — resolved to its URL automatically
item = client.deployed_items.create(
    service_item_id=123,
    change_instance_id=456,
    data={
        "host":     "db-prod-01.internal",
        "port":     5432,
        "database": "myapp",
        "username": "app_user"
    }
)
print(item.id)
print(item.data_field)   # same dict returned as data_field

# Using a URL directly — skips the extra lookup
item = client.deployed_items.create(
    service_item_id=client.service_items.get(123).url,
    change_instance_id=client.change_instances.get(456).url,
    data={"host": "db-prod-01.internal", "port": 5432}
)

update(id, data=None, service_item_id=None, change_instance_id=None)

Records new provisioning output — for example to reflect a failover or configuration change after the initial provisioning.

Issues a single HTTP PATCH with data. The server deep-merges it onto the service item's latest version and saves the result as a new version — previous versions are immutable and preserved for audit. data is the flat provisioning payload — the same shape create() takes, not a {"data": {...}} wrapper. It is appended to, not replaced, recursively: new keys are added, matching keys are updated, and keys you don't mention — including nested ones — are kept.

id must be the latest version for its service item; the server rejects PATCHes against older versions (use update_latest() if you don't have the latest id).

Requires a backend with the deployed_item PATCH-new-version change (!739) deployed.

Parameter Type Description
id int Deployed item ID (must be the latest version)
data dict The provisioning payload fields to merge in
service_item_id int or str Accepted for backward compatibility but ignored — the server derives the FK from the target version
change_instance_id int or str Accepted for backward compatibility but ignored — the server derives the FK from the target version
# Existing payload: {"host": "db-prod-01.internal", "port": 5432}

# Append a new field — existing keys are preserved
client.deployed_items.update(789, {"replica": "db-replica-01.internal"})
# New version's payload: {"host": "db-prod-01.internal", "port": 5432, "replica": "db-replica-01.internal"}

# Update an existing field after a failover — other keys are preserved
client.deployed_items.update(789, {"host": "db-prod-02.internal"})

# Nested dicts are deep-merged — siblings under "tls" are NOT dropped
# Existing: {"tls": {"cert": "a", "key": "b"}}
client.deployed_items.update(789, {"tls": {"cert": "c"}})
# New version's "tls": {"cert": "c", "key": "b"}

delete(id)

Not supported. Deployed items are immutable versions — the API only reads and creates them. Calling this raises NotImplementedError. To record new provisioning output, create a new version with create() / update() / update_latest() instead.

client.deployed_items.delete(789)  # raises NotImplementedError

get_dependant(**filters)

Returns deployed items that depend on other deployed items — i.e. items that require another deployed item to exist before they can be used. Returns a list of raw dicts.

Filters: same as list().

dependants = client.deployed_items.get_dependant()
for dep in dependants:
    print(dep)

by_service_item(service_item_id, **filters)

Returns all deployed items for a service item, newest first by default. Equivalent to filter(service_item_id=service_item_id, ordering="-created", **filters).

items = client.deployed_items.by_service_item(123)
for item in items:
    print(item.id, item.created)

get_latest(service_item_id)

Returns the most recently created deployed item for a service item, or None if it has none.

latest = client.deployed_items.get_latest(123)
if latest:
    print(latest.data_field)

update_latest(service_item_id, data)

Finds the most recently created deployed item for a service item and PATCHes it — get_latest(service_item_id) followed by update(). The server merges the delta and saves a new version. Raises NetorcaNotFoundError if the service item has no deployed item yet.

data is the flat provisioning payload, merged onto the latest version the same way as update().

client.deployed_items.update_latest(123, {"host": "db-prod-02.internal"})