// Copyright 2016-2018, Pulumi Corporation. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. import * as pulumi from "@pulumi/pulumi"; import * as dynamic from "@pulumi/pulumi/dynamic"; export class Provider implements dynamic.ResourceProvider { public static readonly instance = new Provider(); private id: number = 0; public async check(olds: any, news: any): Promise<dynamic.CheckResult> { return { inputs: news, } } public async diff(id: pulumi.ID, olds: any, news: any): Promise<dynamic.DiffResult> { if (news.state !== olds.state) { return { changes: true, replaces: ["state"], deleteBeforeReplace: true, }; } return { changes: false, } } public async create(inputs: any): Promise<dynamic.CreateResult> { return { id: (this.id++).toString(), outs: inputs, } } public async update(id: string, olds: any, news: any): Promise<dynamic.UpdateResult> { throw Error("this resource is replace-only and can't be updated"); } public async read(id: pulumi.ID, props: any): Promise<dynamic.ReadResult> { return { id: id, props: props, } } } export class Resource extends pulumi.dynamic.Resource { public readonly state: pulumi.Output<any>; constructor(name: string, props: any, opts?: pulumi.ResourceOptions) { super(Provider.instance, name, props, opts); } }