Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get Timestamp from AddEntity response in aztables? #22438

Closed
prince776 opened this issue Feb 22, 2024 · 7 comments · Fixed by #22472
Closed

How to get Timestamp from AddEntity response in aztables? #22438

prince776 opened this issue Feb 22, 2024 · 7 comments · Fixed by #22472
Assignees
Labels

Comments

@prince776
Copy link

Hello,
I am using aztables package.

github.com/Azure/azure-sdk-for-go/sdk/data/aztables v1.1.0

As mentioned in the doc, i have created a service client like:

	newTableServiceClient, err := aztables.NewServiceClientWithSharedKey(
		"validEndpoint",
		creds,
		nil, // options
	)

Then I try to add an entity like:

	resp, err = c.newTableServiceClient.NewClient(entity.Table.Name).AddEntity(
		ctx,
		serializedEntity,
		nil, // options
	)

This return value has only the ETag however I also want other metadata fields, especially the timestamp.

This AddEntity method calls InsertEntity method of an internal interface (so I can't use it). Inside this method, all the extra fields I require are present at

	resp, err := client.insertEntityHandleResponse(httpResp)
	return resp, err

(validated manually)

But then this response is trimmed down to only have ETag before the AddEntity method returns (by converting to a minimal type)

I want to know what's the idiomatic/suggested way I can get this information?
The only way I am able to think is adding custom Pipeline policy that we pass to the TableServiceClient:

	// PerCallPolicies contains custom policies to inject into the pipeline.
	// Each policy is executed once per request.
	PerCallPolicies []Policy

	// PerRetryPolicies contains custom policies to inject into the pipeline.
	// Each policy is executed once per request, and for each retry of that request.
	PerRetryPolicies []Policy

but this would be a bit tedious imo, so wanted to consult here.

Thanks

@jhendrixMSFT jhendrixMSFT self-assigned this Feb 22, 2024
@jhendrixMSFT
Copy link
Member

By timestamp I assume you're referring to the Date field in the internal response type yes? I'm not sure why this and other fields weren't exported. I'll follow up on this.

@jhendrixMSFT
Copy link
Member

Oh I think what you want is the Value field.

@prince776
Copy link
Author

@jhendrixMSFT Thanks for the response
You're correct I need the Date field.
However please note that if we specify that we want full metadata and response preference of content
We get date in the Value field as well

So either

  • just exposing the Date field or,
  • allowing more flexibility on query options on the AddEntity and then exposing the Values field
    is required.

@jhendrixMSFT
Copy link
Member

For whatever reason, we disable response metadata and don't provide an option to toggle it. I think it would be best to expose the Value and then add an option to toggle the behavior.

@prince776
Copy link
Author

prince776 commented Feb 23, 2024

Thanks @jhendrixMSFT
Just want to mention that the issue applies to other methods of this client as well.
For example: GetEntity:

func (t *Client) GetEntity(ctx context.Context, partitionKey string, rowKey string, options *GetEntityOptions) (GetEntityResponse, error) {

Here while we do send back the Value in GetEntityResponse we do not allow increasing metadata level using options param as right now it is empty and just hardcodes to minimalMetadata.

@jhendrixMSFT
Copy link
Member

The feature will be available in aztables@v1.2.0 scheduled to release next week on 3/5.

@jhendrixMSFT
Copy link
Member

Unfortunately there was a delay in the release, it's available now.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants