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

Add support for Get/Post/Delete/Patch schemas for API Shield Schema Validation 2.0 #1406

Merged
merged 4 commits into from
Oct 3, 2023

Conversation

djhworld
Copy link

@djhworld djhworld commented Sep 19, 2023

This change adds support for the following API Shield related endpoints related to Schema Validation 2.0:

Description

This change adds support for API Shield related endpoints related to managing schemas for API Shield Schema Validation 2.0. This is so they can be used from the library and will enable this feature to be added to terraform in the future.

Has your change been tested?

  • Unit tests
  • Local testing using API

Types of changes

What sort of change does your code introduce/modify?

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • This change is using publicly documented in cloudflare/api-schemas
    and relies on stable APIs. (API Shield Schema Validation 2.0)

@github-actions
Copy link

github-actions bot commented Sep 19, 2023

changelog detected ✅

@djhworld djhworld force-pushed the dharper/APISHI-2357 branch 2 times, most recently from ed05bd6 to c8bfbf3 Compare September 19, 2023 15:14
Copy link

@hc2116 hc2116 left a comment

Choose a reason for hiding this comment

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

This looks good to me!

uri := fmt.Sprintf("/zones/%s/api_gateway/user_schemas", rc.Identifier)

if params.Name == "" {
return nil, fmt.Errorf("params.Name must not be empty")
Copy link

Choose a reason for hiding this comment

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

Name can in principle be empty, is this specific to Terraform? If it is empty, the file-name will be used

Copy link

Choose a reason for hiding this comment

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

Ah but I guess here we do not have a filename

Copy link
Author

Choose a reason for hiding this comment

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

We don't have a filename in this case as we're passing io.Reader so a name should be provided separately.

var b bytes.Buffer
w := multipart.NewWriter(&b)
// write fields
if err := w.WriteField("name", params.Name); err != nil {
Copy link

Choose a reason for hiding this comment

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

Should we have a check that the name ends in .json or .yaml?

Copy link
Author

Choose a reason for hiding this comment

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

On the backend it's not specified as a requirement so I don't think we should encode any logic like that here.

…eld Schema Validation 2.0

This change adds support for the following API Shield related endpoints related to Schema Validation 2.0:

- Retrieve information about all schemas on a zone
- Retrieve information about a specific schema on a zone
- Upload a schema to a zone
- Enable validation for a schema
- Delete a schema
@djhworld djhworld force-pushed the dharper/APISHI-2357 branch from 5033f86 to 30c87b4 Compare October 3, 2023 16:22
@djhworld djhworld marked this pull request as ready for review October 3, 2023 16:29
@djhworld djhworld requested a review from jacobbednarz as a code owner October 3, 2023 16:29
@djhworld
Copy link
Author

djhworld commented Oct 3, 2023

@jacobbednarz jacobbednarz merged commit 395c17a into cloudflare:master Oct 3, 2023
@github-actions github-actions bot added this to the v0.79.0 milestone Oct 3, 2023
github-actions bot pushed a commit that referenced this pull request Oct 3, 2023
@github-actions
Copy link

This functionality has been released in v0.79.0.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

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

Successfully merging this pull request may close these issues.

3 participants