Skip to content

Conversation

@saehejkang
Copy link
Contributor

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

Closes #665

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

@saehejkang saehejkang changed the title [network-createion]: Add createdAt field [network-creation]: Add createdAt field Oct 21, 2025
@saehejkang
Copy link
Contributor Author

Not sure if I added the createdAt field correctly to the decoder, but I am getting an error when testing any network commands.

Error: keyNotFound(CodingKeys(stringValue: "createdAt", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "running", intValue: nil), RunningCodingKeys(stringValue: "_0", intValue: nil)], debugDescription: "No value associated with key CodingKeys(stringValue: \"createdAt\", intValue: nil) (\"createdAt\").", underlyingError: nil))

Maybe something to do with the encoding and decoding done in the create function here? First time looking into the api/client side of things.

@saehejkang
Copy link
Contributor Author

Not sure the protocol with pinging maintainers, as I don't want to bloat anyone's notifications.

But @jglogan , I would love to get some 👀 on this. Mainly to check if I am even taking the right steps in what we want accomplish here.

@jglogan
Copy link
Contributor

jglogan commented Oct 25, 2025

@saehejkang I'll have a look next week.

@jglogan jglogan self-requested a review October 25, 2025 14:04
@jglogan
Copy link
Contributor

jglogan commented Oct 30, 2025

@saehejkang I'll have a review of this done by the end of the day. The main thing I want to consider is whether what you have here follows a pattern that we can apply to the metadata for all our managed resources.

case .running(let configuration, _): configuration.id
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern could get out of hand as we add more configuration attributes.

Perhaps we could have a public var configuration: NetworkConfiguration? that provides configuration if the state has that associated data (always would for now but it would give us leeway for states that don't)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I understand what you kinda mean? Do we want to update id as well?

public var configuration: NetworkConfiguration? {
   switch self {
      case .created(let configuration): configuration
      case .running(let configuration, _): configuration
   }
}

public var createdAt: Date? {
   configuration?.createdAt
}


public struct PrintableNetwork: Codable {
let id: String
let createdAt: Date
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this in PrintableNetwork if we're not printing it for now, right?

Let's leave it out here and not print the create date in tabular output, to start with.

@saehejkang saehejkang force-pushed the add-new-network-metadata branch from 9fd5f2d to 638912c Compare November 1, 2025 07:03
let container = try decoder.container(keyedBy: CodingKeys.self)

id = try container.decode(String.self, forKey: .id)
createdAt = try container.decode(Date.self, forKey: .createdAt)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Request]: Add Creation Date in Network Metadata

2 participants