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 data source instance #154

Closed
2 tasks done
dikhan opened this issue Sep 27, 2019 · 0 comments · Fixed by #155
Closed
2 tasks done

Add support for data source instance #154

dikhan opened this issue Sep 27, 2019 · 0 comments · Fixed by #155

Comments

@dikhan
Copy link
Owner

dikhan commented Sep 27, 2019

Is your feature request related to a problem?

Currently data sources are supported for root level GET paths (https://github.com/dikhan/terraform-provider-openapi/blob/master/docs/how_to.md#terraform-data-source-compliant-requirements).

Describe the solution you'd like

As a service provider
I want to be able to expose as data resource instance paths (e,g: /v1/cdns/{id}) 
So users can retrieve individual resource instance info by providing the id in the data source configuration

Acceptance criteria

Scenario: fetching an already existing cdn using cdn data source instance
Given an already created cdn with id = 1234 and the swagger file below
When a data resource sl_cdn_v1_instance is configured with id = 1234 and terraform is executed
Then the resulted data source info should contain in the state both the id matching the input id from the user and the corresponding label for that given cdn id.
  • Input swagger file
swagger: "2.0"
paths:
  /v1/cdns/{id}:
    get:
      summary: "Get cdn by id"
      parameters:
      - name: "id"
        in: "path"
        description: "The cdn id that needs to be fetched."
        required: true
        type: "string"
      responses:
        200:
          schema:
            $ref: "#/definitions/ContentDeliveryNetworkV1"
definitions:
  ContentDeliveryNetworkV1:
    type: object
    properties:
      id:
        type: string
        readOnly: true
      label:
        type: string
  • Terraform configuration file using cdn data source instance
data "sl_cdn_v1_instance" "my_cdn" {
  id = "someID"
}

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

This ticket came out of realizing that some use cases may not necesarely need to depend on the list operation as supported in #5 ; but rather just retrieve an already existing resource instance by providing simply its id.

Checklist

Don't forget to go through the checklist to make sure the issue is created properly:

  • I have added a corresponding label (feature request/bug/etc) to the issue (right side menu)
  • I have added this issue to the 'API Terraform Provider' GitHub project (right side menu)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant